Update of /cvsroot/sqlobject/SQLObject/tests
In directory sc8-pr-cvs1:/tmp/cvs-serv14660/tests
Modified Files:
SQLObjectTest.py test.py
Log Message:
Allow non-integer IDs
Index: SQLObjectTest.py
===================================================================
RCS file: /cvsroot/sqlobject/SQLObject/tests/SQLObjectTest.py,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** SQLObjectTest.py 7 Sep 2003 07:05:09 -0000 1.14
--- SQLObjectTest.py 7 Sep 2003 23:36:08 -0000 1.15
***************
*** 95,100 ****
if hasattr(c, '%sDrop' % self.databaseName):
if __connection__.tableExists(c._table):
! __connection__.query(
! getattr(c, '%sDrop' % self.databaseName))
elif hasattr(c, 'drop'):
__connection__.query(c.drop)
--- 95,103 ----
if hasattr(c, '%sDrop' % self.databaseName):
if __connection__.tableExists(c._table):
! sql = getattr(c, '%sDrop' % self.databaseName)
! #if self.debugInserts:
! # print sql
! __connection__.query(sql)
!
elif hasattr(c, 'drop'):
__connection__.query(c.drop)
***************
*** 104,109 ****
if hasattr(c, '%sCreate' % self.databaseName):
if not __connection__.tableExists(c._table):
! __connection__.query(
! getattr(c, '%sCreate' % self.databaseName))
elif hasattr(c, 'create'):
__connection__.query(c.create)
--- 107,115 ----
if hasattr(c, '%sCreate' % self.databaseName):
if not __connection__.tableExists(c._table):
! sql = getattr(c, '%sCreate' % self.databaseName)
! #if self.debugInserts:
! # print sql
! __connection__.query(sql)
!
elif hasattr(c, 'create'):
__connection__.query(c.create)
***************
*** 127,131 ****
global __connection__
conn = globals()[t + "Connection"]()
! SQLObject.databaseName = t
__connection__ = conn
--- 133,137 ----
global __connection__
conn = globals()[t + "Connection"]()
! SQLObjectTest.databaseName = t
__connection__ = conn
Index: test.py
===================================================================
RCS file: /cvsroot/sqlobject/SQLObject/tests/test.py,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** test.py 7 Sep 2003 22:35:09 -0000 1.27
--- test.py 7 Sep 2003 23:36:08 -0000 1.28
***************
*** 662,665 ****
--- 662,708 ----
self.assertEqual(t.name3, 0)
+ ########################################
+ ## String ID test
+ ########################################
+
+ class SOStringID(SQLObject):
+
+ _table = 'so_string_id'
+ val = StringCol(alternateID=True)
+
+ mysqlCreate = """
+ CREATE TABLE IF NOT EXISTS so_string_id (
+ id VARCHAR(50) PRIMARY KEY,
+ val TEXT
+ )
+ """
+
+ postgresCreate = mysqlCreate
+ sqliteCreate = mysqlCreate
+ firebirdCreate = mysqlCreate
+
+ mysqlDrop = """
+ DROP TABLE IF EXISTS so_string_id
+ """
+
+ postgresDrop = """
+ DROP TABLE so_string_id
+ """
+
+ sqliteDrop = postgresDrop
+ firebirdDrop = postgresDrop
+
+ class StringIDTest(SQLObjectTest):
+
+ classes = [SOStringID]
+
+ def testStringID(self):
+ t = SOStringID.new(id='hey', val='whatever')
+ t2 = SOStringID.byVal('whatever')
+ self.assertEqual(t, t2)
+ t3 = SOStringID.new(id='you', val='nowhere')
+ t4 = SOStringID('you')
+ self.assertEqual(t3, t4)
+
########################################
|