Thread: [SQL-CVS] SQLObject/tests test.py,1.15,1.16
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: <ian...@us...> - 2003-05-31 01:59:48
|
Update of /cvsroot/sqlobject/SQLObject/tests In directory sc8-pr-cvs1:/tmp/cvs-serv14231/tests Modified Files: test.py Log Message: Proper test of foreign keys Index: test.py =================================================================== RCS file: /cvsroot/sqlobject/SQLObject/tests/test.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** test.py 24 May 2003 20:48:51 -0000 1.15 --- test.py 31 May 2003 01:59:45 -0000 1.16 *************** *** 55,58 **** --- 55,98 ---- MyClass = TestSO2 + class TestSO3(SQLObject): + name = StringCol(length=10) + other = ForeignKey('TestSO4', default=None) + other2 = KeyCol(foreignKey='TestSO4', default=None) + + class TestSO4(SQLObject): + me = StringCol(length=10) + + class TestCase34(SQLObjectTest): + + classes = [TestSO3, TestSO4] + + def testForeignKey(self): + tc3 = TestSO3.new(name='a') + self.assertEqual(tc3.other, None) + self.assertEqual(tc3.other2, None) + self.assertEqual(tc3.otherID, None) + self.assertEqual(tc3.other2ID, None) + tc4a = TestSO4.new(me='1') + tc3.other = tc4a + self.assertEqual(tc3.other, tc4a) + self.assertEqual(tc3.otherID, tc4a.id) + tc4b = TestSO4.new(me='2') + tc3.other = tc4b.id + self.assertEqual(tc3.other, tc4b) + self.assertEqual(tc3.otherID, tc4b.id) + tc4c = TestSO4.new(me='3') + tc3.other2 = tc4c + self.assertEqual(tc3.other2, tc4c) + self.assertEqual(tc3.other2ID, tc4c.id) + tc4d = TestSO4.new(me='4') + tc3.other2 = tc4d.id + self.assertEqual(tc3.other2, tc4d) + self.assertEqual(tc3.other2ID, tc4d.id) + + + + + + ######################################## ## Delete during select |