[SQL-CVS] r4391 - SQLObject/branches/1.0/sqlobject/tests
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: <sub...@co...> - 2011-05-29 11:42:00
|
Author: phd Date: Sun May 29 05:41:53 2011 New Revision: 4391 Log: Merged revision 4390 from branch 0.15: added orderBy to the join column to fix order. Modified: SQLObject/branches/1.0/sqlobject/tests/test_views.py Modified: SQLObject/branches/1.0/sqlobject/tests/test_views.py ============================================================================== --- SQLObject/branches/1.0/sqlobject/tests/test_views.py Sun May 29 05:40:20 2011 (r4390) +++ SQLObject/branches/1.0/sqlobject/tests/test_views.py Sun May 29 05:41:53 2011 (r4391) @@ -6,17 +6,17 @@ number = StringCol() calls = SQLMultipleJoin('PhoneCall') incoming = SQLMultipleJoin('PhoneCall', joinColumn='toID') - + class PhoneCall(SQLObject): phoneNumber = ForeignKey('PhoneNumber') to = ForeignKey('PhoneNumber') minutes = IntCol() - + class ViewPhoneCall(ViewSQLObject): class sqlmeta: idName = PhoneCall.q.id clause = PhoneCall.q.phoneNumberID==PhoneNumber.q.id - + minutes = IntCol(dbName=PhoneCall.q.minutes) number = StringCol(dbName=PhoneNumber.q.number) phoneNumber = ForeignKey('PhoneNumber', dbName=PhoneNumber.q.id) @@ -26,20 +26,21 @@ class sqlmeta: idName = PhoneNumber.q.id clause = PhoneCall.q.phoneNumberID==PhoneNumber.q.id - + minutes = IntCol(dbName=func.SUM(PhoneCall.q.minutes)) numberOfCalls = IntCol(dbName=func.COUNT(PhoneCall.q.phoneNumberID)) number = StringCol(dbName=PhoneNumber.q.number) phoneNumber = ForeignKey('PhoneNumber', dbName=PhoneNumber.q.id) calls = SQLMultipleJoin('PhoneCall', joinColumn='phoneNumberID') - vCalls = SQLMultipleJoin('ViewPhoneCall', joinColumn='phoneNumberID') + vCalls = SQLMultipleJoin('ViewPhoneCall', joinColumn='phoneNumberID', + orderBy='id') class ViewPhoneMore(ViewSQLObject): ''' View on top of view ''' class sqlmeta: idName = ViewPhone.q.id clause = ViewPhone.q.id == PhoneCall.q.toID - + number = StringCol(dbName=ViewPhone.q.number) timesCalled = IntCol(dbName=func.COUNT(PhoneCall.q.toID)) timesCalledLong = IntCol(dbName=func.COUNT(PhoneCall.q.toID)) @@ -49,13 +50,13 @@ class ViewPhoneMore2(ViewPhoneMore): class sqlmeta: table = 'vpm' - + class ViewPhoneInnerAggregate(ViewPhone): twiceMinutes = IntCol(dbName=func.SUM(PhoneCall.q.minutes)*2) def setup_module(mod): - setupClass([mod.PhoneNumber,mod.PhoneCall]) + setupClass([mod.PhoneNumber, mod.PhoneCall]) mod.ViewPhoneCall._connection = mod.PhoneNumber._connection mod.ViewPhone._connection = mod.PhoneNumber._connection mod.ViewPhoneMore._connection = mod.PhoneNumber._connection @@ -122,12 +123,12 @@ assert s.count() == len(phones) s = ViewPhoneCall.select() assert s.count() == len(calls) - + def testSelect2(): s = ViewPhone.select(ViewPhone.q.number==phones[0].number) assert s.getOne().phoneNumber == phones[0] - + def testDistinctCount(): # This test is for SelectResults non-* based count when distinct # We're really just checking this doesn't raise anything due to lack of sqlrepr'ing - assert ViewPhone.select(distinct=True).count() == 2 \ No newline at end of file + assert ViewPhone.select(distinct=True).count() == 2 |