Thread: [SQL-CVS] SQLObject/tests SQLObjectTest.py,1.6,1.7 test.py,1.7,1.8
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: <ian...@us...> - 2003-04-19 00:04:11
|
Update of /cvsroot/sqlobject/SQLObject/tests In directory sc8-pr-cvs1:/tmp/cvs-serv4903/tests Modified Files: SQLObjectTest.py test.py Log Message: * Added Postgres support for _fromDatabase * Moved guessClass out of Col, into DBConnection classes * Changed tests so Postgres gets tested too Index: SQLObjectTest.py =================================================================== RCS file: /cvsroot/sqlobject/SQLObject/tests/SQLObjectTest.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** SQLObjectTest.py 8 Apr 2003 03:01:33 -0000 1.6 --- SQLObjectTest.py 19 Apr 2003 00:04:08 -0000 1.7 *************** *** 20,24 **** def postgresConnection(): SQLObjectTest.supportDynamic = True ! SQLObjectTest.supportAuto = False return PostgresConnection(db='test') --- 20,24 ---- def postgresConnection(): SQLObjectTest.supportDynamic = True ! SQLObjectTest.supportAuto = True return PostgresConnection(db='test') *************** *** 28,31 **** --- 28,33 ---- return SQLiteConnection('data/sqlite.data') + databaseName = None + supportedDatabases = ['mysql', 'postgres', 'sqlite', 'dbm'] *************** *** 45,53 **** c._connection = __connection__ for c in self.classes + [self]: ! if hasattr(c, 'drop'): __connection__.query(c.drop) elif hasattr(c, 'dropTable'): c.dropTable(ifExists=True) ! if hasattr(c, 'create'): __connection__.query(c.create) elif hasattr(c, 'createTable'): --- 47,64 ---- c._connection = __connection__ for c in self.classes + [self]: ! if hasattr(c, '%sDrop' % databaseName): ! if __connection__.tableExists(c._table): ! __connection__.query( ! getattr(c, '%sDrop' % databaseName)) ! elif hasattr(c, 'drop'): __connection__.query(c.drop) elif hasattr(c, 'dropTable'): c.dropTable(ifExists=True) ! ! if hasattr(c, '%sCreate' % databaseName): ! if not __connection__.tableExists(c._table): ! __connection__.query( ! getattr(c, '%sCreate' % databaseName)) ! elif hasattr(c, 'create'): __connection__.query(c.create) elif hasattr(c, 'createTable'): *************** *** 69,73 **** --- 80,86 ---- def setDatabaseType(t): global __connection__ + global databaseName conn = globals()[t + "Connection"]() + databaseName = t __connection__ = conn Index: test.py =================================================================== RCS file: /cvsroot/sqlobject/SQLObject/tests/test.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** test.py 17 Apr 2003 07:15:17 -0000 1.7 --- test.py 19 Apr 2003 00:04:08 -0000 1.8 *************** *** 161,165 **** first_name VARCHAR(100), last_name VARCHAR(200) NOT NULL, ! age INT, created DATETIME NOT NULL, happy char(1) DEFAULT 'Y' NOT NULL --- 161,165 ---- first_name VARCHAR(100), last_name VARCHAR(200) NOT NULL, ! age INT DEFAULT NULL, created DATETIME NOT NULL, happy char(1) DEFAULT 'Y' NOT NULL *************** *** 172,177 **** first_name VARCHAR(100), last_name VARCHAR(200) NOT NULL, ! age INT, ! created DATETIME NOT NULL, happy char(1) DEFAULT 'Y' NOT NULL ) --- 172,177 ---- first_name VARCHAR(100), last_name VARCHAR(200) NOT NULL, ! age INT DEFAULT 0, ! created VARCHAR(40) NOT NULL, happy char(1) DEFAULT 'Y' NOT NULL ) *************** *** 186,192 **** --- 186,198 ---- """ + _table = 'auto_test' + def testClassCreate(self): if not self.supportAuto: return + import sys + reg = sys.modules[SQLObject.__module__].classRegistry + if reg.has_key('AutoTest'): + del reg['AutoTest'] class AutoTest(SQLObject): _fromDatabase = True *************** *** 198,202 **** AutoTest.new(firstName='jane', lastName='doe', ! happy='N') ######################################## --- 204,209 ---- AutoTest.new(firstName='jane', lastName='doe', ! happy='N', ! created=DateTime.now()) ######################################## |