diff options
Diffstat (limited to 'test/orm/eager_relations.py')
| -rw-r--r-- | test/orm/eager_relations.py | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/test/orm/eager_relations.py b/test/orm/eager_relations.py index 73d5b11dc..e42ef5cb8 100644 --- a/test/orm/eager_relations.py +++ b/test/orm/eager_relations.py @@ -1,6 +1,6 @@ """basic tests of eager loaded attributes""" -import testbase +import testenv; testenv.configure_for_tests() from sqlalchemy import * from sqlalchemy.orm import * from testlib import * @@ -139,7 +139,7 @@ class EagerTest(FixtureTest): assert a.user_id==7 # assert that the eager loader added 'user_id' to the row # and deferred loading of that col was disabled - self.assert_sql_count(testbase.db, go, 0) + self.assert_sql_count(testing.db, go, 0) # do the mapping in reverse # (we would have just used an "addresses" backref but the test fixtures then require the whole @@ -161,7 +161,7 @@ class EagerTest(FixtureTest): assert u.addresses[0].user_id==7 # assert that the eager loader didn't have to affect 'user_id' here # and that its still deferred - self.assert_sql_count(testbase.db, go, 1) + self.assert_sql_count(testing.db, go, 1) clear_mappers() @@ -177,7 +177,7 @@ class EagerTest(FixtureTest): def go(): u = sess.query(User).limit(1).get(8) assert User(id=8, addresses=[Address(id=2, dingalings=[Dingaling(id=1)]), Address(id=3), Address(id=4)]) == u - self.assert_sql_count(testbase.db, go, 1) + self.assert_sql_count(testing.db, go, 1) def test_many_to_many(self): @@ -189,11 +189,11 @@ class EagerTest(FixtureTest): q = create_session().query(Item) def go(): assert fixtures.item_keyword_result == q.all() - self.assert_sql_count(testbase.db, go, 1) + self.assert_sql_count(testing.db, go, 1) def go(): assert fixtures.item_keyword_result[0:2] == q.join('keywords').filter(keywords.c.name == 'red').all() - self.assert_sql_count(testbase.db, go, 1) + self.assert_sql_count(testing.db, go, 1) def test_eager_option(self): @@ -207,7 +207,7 @@ class EagerTest(FixtureTest): def go(): assert fixtures.item_keyword_result[0:2] == q.options(eagerload('keywords')).join('keywords').filter(keywords.c.name == 'red').all() - self.assert_sql_count(testbase.db, go, 1) + self.assert_sql_count(testing.db, go, 1) def test_cyclical(self): """test that a circular eager relationship breaks the cycle with a lazy loader""" @@ -259,7 +259,7 @@ class EagerTest(FixtureTest): User(id=10) ] == q.all() - self.assert_sql_count(testbase.db, go, 1) + self.assert_sql_count(testing.db, go, 1) def test_double_same_mappers(self): """tests eager loading with two relations simulatneously, from the same table, using aliases. """ @@ -299,7 +299,7 @@ class EagerTest(FixtureTest): User(id=10) ] == q.all() - self.assert_sql_count(testbase.db, go, 1) + self.assert_sql_count(testing.db, go, 1) def test_no_false_hits(self): """test that eager loaders don't interpret main table columns as part of their eager load.""" @@ -362,7 +362,7 @@ class EagerTest(FixtureTest): def go(): l = q.filter(s.c.u2_id==User.c.id).distinct().all() assert fixtures.user_address_result == l - self.assert_sql_count(testbase.db, go, 1) + self.assert_sql_count(testing.db, go, 1) @testing.fails_on('maxdb') def test_limit_2(self): @@ -444,7 +444,7 @@ class EagerTest(FixtureTest): def go(): l = q.filter(users.c.id == 7).all() assert [User(id=7, address=Address(id=1))] == l - self.assert_sql_count(testbase.db, go, 1) + self.assert_sql_count(testing.db, go, 1) @testing.fails_on('maxdb') def test_many_to_one(self): @@ -459,7 +459,7 @@ class EagerTest(FixtureTest): assert a.user is not None u1 = sess.query(User).get(7) assert a.user is u1 - self.assert_sql_count(testbase.db, go, 1) + self.assert_sql_count(testing.db, go, 1) def test_one_and_many(self): @@ -480,7 +480,7 @@ class EagerTest(FixtureTest): def go(): assert fixtures.user_order_result[0:3] == l.all() - self.assert_sql_count(testbase.db, go, 1) + self.assert_sql_count(testing.db, go, 1) def test_double_with_aggregate(self): @@ -510,7 +510,7 @@ class EagerTest(FixtureTest): ), User(id=10), ] == q.all() - self.assert_sql_count(testbase.db, go, 1) + self.assert_sql_count(testing.db, go, 1) def test_wide(self): mapper(Order, orders, properties={'items':relation(Item, secondary=order_items, lazy=False, order_by=items.c.id)}) @@ -619,7 +619,7 @@ class AddEntityTest(FixtureTest): def go(): ret = sess.query(User).add_entity(Order).join('orders', aliased=True).order_by(User.id).order_by(Order.id).all() self.assertEquals(ret, self._assert_result()) - self.assert_sql_count(testbase.db, go, 1) + self.assert_sql_count(testing.db, go, 1) def test_options(self): mapper(User, users, properties={ @@ -637,13 +637,13 @@ class AddEntityTest(FixtureTest): def go(): ret = sess.query(User).options(eagerload('addresses')).add_entity(Order).join('orders', aliased=True).order_by(User.id).order_by(Order.id).all() self.assertEquals(ret, self._assert_result()) - self.assert_sql_count(testbase.db, go, 6) + self.assert_sql_count(testing.db, go, 6) sess.clear() def go(): ret = sess.query(User).options(eagerload('addresses')).add_entity(Order).options(eagerload('items', Order)).join('orders', aliased=True).order_by(User.id).order_by(Order.id).all() self.assertEquals(ret, self._assert_result()) - self.assert_sql_count(testbase.db, go, 1) + self.assert_sql_count(testing.db, go, 1) class SelfReferentialEagerTest(ORMTest): def define_tables(self, metadata): @@ -684,7 +684,7 @@ class SelfReferentialEagerTest(ORMTest): ]), Node(data='n13') ]) == d - self.assert_sql_count(testbase.db, go, 1) + self.assert_sql_count(testing.db, go, 1) def test_lazy_fallback_doesnt_affect_eager(self): @@ -726,7 +726,7 @@ class SelfReferentialEagerTest(ORMTest): Node(data='n122'), Node(data='n123') ] == list(n12.children) - self.assert_sql_count(testbase.db, go, 1) + self.assert_sql_count(testing.db, go, 1) def test_with_deferred(self): class Node(Base): @@ -747,19 +747,19 @@ class SelfReferentialEagerTest(ORMTest): def go(): assert Node(data='n1', children=[Node(data='n11'), Node(data='n12')]) == sess.query(Node).first() - self.assert_sql_count(testbase.db, go, 4) + self.assert_sql_count(testing.db, go, 4) sess.clear() def go(): assert Node(data='n1', children=[Node(data='n11'), Node(data='n12')]) == sess.query(Node).options(undefer('data')).first() - self.assert_sql_count(testbase.db, go, 3) + self.assert_sql_count(testing.db, go, 3) sess.clear() def go(): assert Node(data='n1', children=[Node(data='n11'), Node(data='n12')]) == sess.query(Node).options(undefer('data'), undefer('children.data')).first() - self.assert_sql_count(testbase.db, go, 1) + self.assert_sql_count(testing.db, go, 1) @@ -793,7 +793,7 @@ class SelfReferentialEagerTest(ORMTest): ]), Node(data='n13') ]) == d - self.assert_sql_count(testbase.db, go, 2) + self.assert_sql_count(testing.db, go, 2) def go(): d = sess.query(Node).filter_by(data='n1').options(eagerload('children.children')).first() @@ -802,7 +802,7 @@ class SelfReferentialEagerTest(ORMTest): # testing only sqlite for now since the query text is slightly different on other # dialects if testing.against('sqlite'): - self.assert_sql(testbase.db, go, [ + self.assert_sql(testing.db, go, [ ( "SELECT nodes.id AS nodes_id, nodes.parent_id AS nodes_parent_id, nodes.data AS nodes_data FROM nodes WHERE nodes.data = :nodes_data_1 ORDER BY nodes.oid LIMIT 1 OFFSET 0", {'nodes_data_1': 'n1'} @@ -840,7 +840,7 @@ class SelfReferentialEagerTest(ORMTest): ]), Node(data='n13') ]) == d - self.assert_sql_count(testbase.db, go, 3) + self.assert_sql_count(testing.db, go, 3) class SelfReferentialM2MEagerTest(ORMTest): def define_tables(self, metadata): @@ -919,4 +919,4 @@ class CyclicalInheritingEagerTest(ORMTest): create_session().query(SubT).all() if __name__ == '__main__': - testbase.main() + testenv.main() |
