From: Mike Bayer Date: Thu, 26 Jan 2006 00:28:10 +0000 (+0000) Subject: test for inheritance, tests objectstore post_exec works fully X-Git-Tag: rel_0_1_0~104 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=01f9705a80000ceabf4d7d757072c35cbd75235b;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git test for inheritance, tests objectstore post_exec works fully --- diff --git a/test/objectstore.py b/test/objectstore.py index 6ddabafce4..ddd39b35d5 100644 --- a/test/objectstore.py +++ b/test/objectstore.py @@ -22,7 +22,7 @@ class HistoryTest(AssertMixin): def setUp(self): objectstore.clear() clear_mappers() - + def testattr(self): """tests the rolling back of scalar and list attributes. this kind of thing should be tested mostly in attributes.py which tests independently of the ORM @@ -139,6 +139,10 @@ class SaveTest(AssertMixin): db.commit() tables.delete() db.echo = testbase.echo + + self.assert_(len(objectstore.uow().new) == 0) + self.assert_(len(objectstore.uow().dirty) == 0) + self.assert_(len(objectstore.uow().modified_lists) == 0) def testbasic(self): # save two users @@ -177,6 +181,25 @@ class SaveTest(AssertMixin): self.assert_(u.user_id == userlist[0].user_id and userlist[0].user_name == 'modifiedname') self.assert_(u2.user_id == userlist[1].user_id and userlist[1].user_name == 'savetester2') + def testinherits(self): + m1 = mapper(User, users) + + class AddressUser(User): + """a user object that also has the users mailing address.""" + pass + + # define a mapper for AddressUser that inherits the User.mapper, and joins on the user_id column + AddressUser.mapper = mapper( + AddressUser, + addresses, inherits=m1 + ) + + au = AddressUser() + objectstore.commit() + objectstore.clear() + l = AddressUser.mapper.selectone() + self.assert_(l.user_id == au.user_id and l.address_id == au.address_id) + def testmultitable(self): """tests a save of an object where each instance spans two tables. also tests redefinition of the keynames for the column properties.""" @@ -488,7 +511,6 @@ class SaveTest(AssertMixin): u2.user_name = 'user2modified' u1.addresses.append(a3) del u1.addresses[0] - u1.addresses.foo = True self.assert_sql(db, lambda: objectstore.commit(), [ (