[SQL-CVS] r273 - in trunk/SQLObject: sqlobject tests
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: <sub...@co...> - 2004-10-07 12:10:49
|
Author: bbollenbach Date: 2004-10-07 03:57:16 -0400 (Thu, 07 Oct 2004) New Revision: 273 Modified: trunk/SQLObject/sqlobject/joins.py trunk/SQLObject/tests/test.py Log: Andrew Bennetts' patch to create join methods correctly, even if they're = not named explicitly. I've done some slight renaming to hopefully more clearl= y describe what's being tested. Modified: trunk/SQLObject/sqlobject/joins.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/SQLObject/sqlobject/joins.py 2004-10-06 01:23:42 UTC (rev 272) +++ trunk/SQLObject/sqlobject/joins.py 2004-10-07 07:57:16 UTC (rev 273) @@ -29,6 +29,8 @@ def _get_joinMethodName(self): return self._joinMethodName =20 + joinMethodName =3D property(_get_joinMethodName, _set_joinMethodName= ) + def withClass(self, soClass): if self.kw.has_key('joinMethodName'): self._joinMethodName =3D self.kw['joinMethodName'] Modified: trunk/SQLObject/tests/test.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/SQLObject/tests/test.py 2004-10-06 01:23:42 UTC (rev 272) +++ trunk/SQLObject/tests/test.py 2004-10-07 07:57:16 UTC (rev 273) @@ -38,18 +38,6 @@ else: self.fail("should have raised an error on duplicate class de= finition") =20 -## class Billboard(SQLObject): -## message =3D StringCol() - -## class UnicodeTest(SQLObjectTest): -## classes =3D [Billboard] - -## def testUnicodeStrings(self): -## try: -## b =3D Billboard(message =3D u"foobar") -## except Exception, err: -## self.fail("shouldn't have raised an exception.") - ######################################## ## Basic operation ######################################## @@ -741,6 +729,12 @@ _columns =3D [StringCol('zip', length=3D5, alternateID=3DTrue)] _joins =3D [RelatedJoin('PersonJoiner')] =20 +class ImplicitJoiningSO(SQLObject): + foo =3D RelatedJoin('Bar') + +class ExplicitJoiningSO(SQLObject): + _joins =3D [MultipleJoin('Bar', joinMethodName=3D'foo')] + class JoinTest(SQLObjectTest): =20 classes =3D [PersonJoiner, AddressJoiner] @@ -772,6 +766,15 @@ def assertNamesEqual(self, people, dest): self.assertEqual([p.name for p in people], dest) =20 + def testJoinAttributeWithUnderscores(self): + # Make sure that the implicit setting of joinMethodName works + self.failUnless(hasattr(ImplicitJoiningSO, 'foo')) + self.failIf(hasattr(ImplicitJoiningSO, 'bars')) + + # And make sure explicit setting also works + self.failUnless(hasattr(ExplicitJoiningSO, 'foo')) + self.failIf(hasattr(ExplicitJoiningSO, 'bars')) + class PersonJoiner2(SQLObject): =20 _columns =3D [StringCol('name', length=3D40, alternateID=3DTrue)] |