[SQL-CVS] SQLObject/tests test.py,1.31,1.32
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: <ian...@us...> - 2003-09-27 22:55:53
|
Update of /cvsroot/sqlobject/SQLObject/tests In directory sc8-pr-cvs1:/tmp/cvs-serv10975/tests Modified Files: test.py Log Message: * Added a style test. Not very complete yet. * Some fixes for Firebird tests. Index: test.py =================================================================== RCS file: /cvsroot/sqlobject/SQLObject/tests/test.py,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** test.py 26 Sep 2003 07:13:00 -0000 1.31 --- test.py 27 Sep 2003 22:55:40 -0000 1.32 *************** *** 216,220 **** except IndexError: pass ! self.failIf(count != len(self.names)) --- 216,220 ---- except IndexError: pass ! self.assertEqual(count, len(self.names)) *************** *** 692,697 **** """ sqliteCreate = postgresCreate - firebirdCreate = postgresCreate mysqlDrop = """ --- 692,703 ---- """ + firebirdCreate = """ + CREATE TABLE so_string_id ( + id VARCHAR(50) NOT NULL PRIMARY KEY, + val BLOB SUB_TYPE TEXT + ) + """ + sqliteCreate = postgresCreate mysqlDrop = """ *************** *** 718,721 **** --- 724,756 ---- self.assertEqual(t3, t4) + + + class AnotherStyle(MixedCaseUnderscoreStyle): + def pythonAttrToDBColumn(self, attr): + if attr.lower().endswith('id'): + return 'id'+MixedCaseUnderscoreStyle.pythonAttrToDBColumn(self, attr[:-2]) + else: + return MixedCaseUnderscoreStyle.pythonAttrToDBColumn(self, attr) + + class SOStyleTest1(SQLObject): + a = StringCol() + st2 = ForeignKey('SOStyleTest2') + _style = AnotherStyle() + + class SOStyleTest2(SQLObject): + b = StringCol() + _style = AnotherStyle() + + class StyleTest(SQLObjectTest): + + classes = [SOStyleTest1, SOStyleTest2] + + + def test(self): + st1 = SOStyleTest1.new(a='something', st2=None) + st2 = SOStyleTest2.new(b='whatever') + st1.st2 = st2 + self.assertEqual(st1._SO_columnDict['st2ID'].dbName, 'idst2') + self.assertEqual(st1.st2, st2) ######################################## |