[SQL-CVS] SQLObject/tests test.py,1.10,1.11
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: <ian...@us...> - 2003-05-06 21:02:05
|
Update of /cvsroot/sqlobject/SQLObject/tests In directory sc8-pr-cvs1:/tmp/cvs-serv29477/tests Modified Files: test.py Log Message: Added a test of MultipleJoin Index: test.py =================================================================== RCS file: /cvsroot/sqlobject/SQLObject/tests/test.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** test.py 5 May 2003 17:35:20 -0000 1.10 --- test.py 6 May 2003 21:02:00 -0000 1.11 *************** *** 33,36 **** --- 33,45 ---- self.assertEqual(bob.passwd, 'god'.encode('rot13')) + class TestCaseGetSet(TestCase1): + + def testGet(self): + bob = TestSO1.selectBy(name='bob')[0] + self.assertEqual(bob.name, 'bob') + bob.name = 'joe' + self.assertEqual(bob.name, 'joe') + + ######################################## ## Delete during select *************** *** 298,301 **** --- 307,348 ---- def assertNamesEqual(self, people, dest): self.assertEqual([p.name for p in people], dest) + + class PersonJoiner2(SQLObject): + + _columns = [StringCol('name', length=40, alternateID=True)] + _joins = [MultipleJoin('AddressJoiner2')] + + class AddressJoiner2(SQLObject): + + _columns = [StringCol('zip', length=5), + KeyCol('personJoiner2ID', foreignKey='PersonJoiner2')] + + class JoinTest2(SQLObjectTest): + + classes = [PersonJoiner2, AddressJoiner2] + + def inserts(self): + p1 = PersonJoiner2.new(name='bob') + p2 = PersonJoiner2.new(name='sally') + for z in ['11111', '22222', '33333']: + a = AddressJoiner2.new(zip=z, personJoiner2=p1) + #p1.addAddressJoiner2(a) + AddressJoiner2.new(zip='00000', personJoiner2=p2) + + def test(self): + bob = PersonJoiner2.byName('bob') + sally = PersonJoiner2.byName('sally') + self.assertEqual(len(bob.addressJoiner2s), 3) + self.assertEqual(len(sally.addressJoiner2s), 1) + bob.addressJoiner2s[0].destroySelf() + self.assertEqual(len(bob.addressJoiner2s), 2) + z = bob.addressJoiner2s[0] + z.zip = 'xxxxx' + id = z.id + del z + z = AddressJoiner2(id) + self.assertEqual(z.zip, 'xxxxx') + + ######################################## |