[SQL-CVS] r790 - trunk/SQLObject/sqlobject/tests
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: <sub...@co...> - 2005-05-13 18:20:39
|
Author: ianb Date: 2005-05-13 18:20:29 +0000 (Fri, 13 May 2005) New Revision: 790 Modified: trunk/SQLObject/sqlobject/tests/test_basic.py Log: Added some more tests of selectBy and stuff (that already passed anyway) Modified: trunk/SQLObject/sqlobject/tests/test_basic.py =================================================================== --- trunk/SQLObject/sqlobject/tests/test_basic.py 2005-05-10 19:27:15 UTC (rev 789) +++ trunk/SQLObject/sqlobject/tests/test_basic.py 2005-05-13 18:20:29 UTC (rev 790) @@ -23,6 +23,8 @@ bob = TestSO1.selectBy(name='bob')[0] assert bob.name == 'bob' assert bob.passwd == 'god'.encode('rot13') + bobs = TestSO1.selectBy(name='bob')[:10] + assert len(list(bobs)) == 1 def test_newline(): setupGetters(TestSO1) @@ -107,6 +109,19 @@ tcc2 = TestSO3(name='c', other=tc4a.id) assert tcc2.other == tc4a +def test_selectBy(): + setupClass([TestSO4, TestSO3]) + tc4 = TestSO4(me='another') + tc3 = TestSO3(name='sel', other=tc4) + anothertc3 = TestSO3(name='not joined') + assert tc3.other == tc4 + assert list(TestSO3.selectBy(other=tc4)) == [tc3] + assert list(TestSO3.selectBy(otherID=tc4.id)) == [tc3] + assert TestSO3.selectBy(otherID=tc4.id)[0] == tc3 + assert list(TestSO3.selectBy(otherID=tc4.id)[:10]) == [tc3] + assert list(TestSO3.selectBy(other=tc4)[:10]) == [tc3] + assert 0 + class TestSO5(SQLObject): name = StringCol(length=10, dbName='name_col') other = ForeignKey('TestSO6', default=None, cascade=True) |