diff options
| author | Jason Kirtland <jek@discorporate.us> | 2008-01-12 22:03:42 +0000 |
|---|---|---|
| committer | Jason Kirtland <jek@discorporate.us> | 2008-01-12 22:03:42 +0000 |
| commit | 17d3c8764e020379e54053bca0b0a2bc71d48aa0 (patch) | |
| tree | 0b46f1ddc57292b8f5bfbc28ab1679230f63e426 /test/orm/inheritance/query.py | |
| parent | c194962019d1bc7322e20b82c33aa1bab3bc2a28 (diff) | |
| download | sqlalchemy-17d3c8764e020379e54053bca0b0a2bc71d48aa0.tar.gz | |
- testbase is gone, replaced by testenv
- Importing testenv has no side effects- explicit functions provide similar behavior to the old immediate behavior of testbase
- testing.db has the configured db
- Fixed up the perf/* scripts
Diffstat (limited to 'test/orm/inheritance/query.py')
| -rw-r--r-- | test/orm/inheritance/query.py | 50 |
1 files changed, 24 insertions, 26 deletions
diff --git a/test/orm/inheritance/query.py b/test/orm/inheritance/query.py index ee837baed..bace4e6cf 100644 --- a/test/orm/inheritance/query.py +++ b/test/orm/inheritance/query.py @@ -3,7 +3,7 @@ and inheriting mappers.""" # TODO: under construction ! -import testbase +import testenv; testenv.configure_for_tests() import sets from sqlalchemy import * from sqlalchemy.orm import * @@ -12,7 +12,7 @@ from testlib import fixtures class Company(fixtures.Base): pass - + class Person(fixtures.Base): pass class Engineer(Person): @@ -28,44 +28,44 @@ class Paperwork(fixtures.Base): class PolymorphicQueryTest(ORMTest): keep_data = True keep_mappers = True - + def define_tables(self, metadata): global companies, people, engineers, managers, boss, paperwork - - companies = Table('companies', metadata, + + companies = Table('companies', metadata, Column('company_id', Integer, Sequence('company_id_seq', optional=True), primary_key=True), Column('name', String(50))) - people = Table('people', metadata, + people = Table('people', metadata, Column('person_id', Integer, Sequence('person_id_seq', optional=True), primary_key=True), Column('company_id', Integer, ForeignKey('companies.company_id')), Column('name', String(50)), Column('type', String(30))) - engineers = Table('engineers', metadata, + engineers = Table('engineers', metadata, Column('person_id', Integer, ForeignKey('people.person_id'), primary_key=True), Column('status', String(30)), Column('engineer_name', String(50)), Column('primary_language', String(50)), ) - managers = Table('managers', metadata, + managers = Table('managers', metadata, Column('person_id', Integer, ForeignKey('people.person_id'), primary_key=True), Column('status', String(30)), Column('manager_name', String(50)) ) - boss = Table('boss', metadata, + boss = Table('boss', metadata, Column('boss_id', Integer, ForeignKey('managers.person_id'), primary_key=True), Column('golf_swing', String(30)), ) - paperwork = Table('paperwork', metadata, + paperwork = Table('paperwork', metadata, Column('paperwork_id', Integer, primary_key=True), - Column('description', String(50)), + Column('description', String(50)), Column('person_id', Integer, ForeignKey('people.person_id'))) - - # create the most awkward polymorphic selects possible; + + # create the most awkward polymorphic selects possible; # the union does not include the "people" table by itself nor does it have # "people.person_id" directly in it, and it also does not include at all # the "boss" table @@ -74,14 +74,14 @@ class PolymorphicQueryTest(ORMTest): 'engineer':people.join(engineers), 'manager':people.join(managers), }, None, 'pjoin') - - # separate join for second-level inherit + + # separate join for second-level inherit manager_join = people.join(managers).outerjoin(boss) mapper(Company, companies, properties={ 'employees':relation(Person) }) - mapper(Person, people, select_table=person_join, polymorphic_on=people.c.type, polymorphic_identity='person', order_by=person_join.c.person_id, + mapper(Person, people, select_table=person_join, polymorphic_on=people.c.type, polymorphic_identity='person', order_by=person_join.c.person_id, properties={ 'paperwork':relation(Paperwork) }) @@ -89,7 +89,7 @@ class PolymorphicQueryTest(ORMTest): mapper(Manager, managers, select_table=manager_join, inherits=Person, polymorphic_identity='manager') mapper(Boss, boss, inherits=Manager, polymorphic_identity='boss') mapper(Paperwork, paperwork) - + def insert_data(self): c1 = Company(name="MegaCorp, Inc.") c2 = Company(name="Elbonia, Inc.") @@ -109,7 +109,7 @@ class PolymorphicQueryTest(ORMTest): Paperwork(description="review #3") ]) c1.employees = [e1, e2, b1, m1] - + e3 = Engineer(name="vlad", engineer_name="vlad", primary_language="cobol", status="elbonian engineer") c2.employees = [e3] sess = create_session() @@ -117,19 +117,17 @@ class PolymorphicQueryTest(ORMTest): sess.save(c2) sess.flush() sess.clear() - + global all_employees, c1_employees, c2_employees all_employees = [e1, e2, b1, m1, e3] c1_employees = [e1, e2, b1, m1] c2_employees = [e3] - + def test_load_all(self): sess = create_session() - + self.assertEquals(sess.query(Person).all(), all_employees) -if __name__ == "__main__": - testbase.main() - - -
\ No newline at end of file + +if __name__ == "__main__": + testenv.main() |
