Update of /cvsroot/sqlobject/SQLObject/tests
In directory sc8-pr-cvs1:/tmp/cvs-serv18414/tests
Modified Files:
SQLObjectTest.py test.py
Log Message:
* Made the EnumCol use Postgres' constraints
* Small Enum test
* Made alternateID imply unique
Index: SQLObjectTest.py
===================================================================
RCS file: /cvsroot/sqlobject/SQLObject/tests/SQLObjectTest.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** SQLObjectTest.py 19 Apr 2003 00:04:08 -0000 1.7
--- SQLObjectTest.py 19 Apr 2003 00:54:25 -0000 1.8
***************
*** 7,10 ****
--- 7,13 ----
SQLObjectTest.supportDynamic = True
SQLObjectTest.supportAuto = True
+ # @@: MySQL *should* support this, but it appears not to
+ # care when you assign incorrect to an ENUM...
+ SQLObjectTest.supportRestrictedEnum = False
return MySQLConnection(host='localhost',
db='test',
***************
*** 16,19 ****
--- 19,23 ----
SQLObjectTest.supportDynamic = True
SQLObjectTest.supportAuto = False
+ SQLObjectTest.supportRestrictedEnum = False
return DBMConnection('data')
***************
*** 21,24 ****
--- 25,29 ----
SQLObjectTest.supportDynamic = True
SQLObjectTest.supportAuto = True
+ SQLObjectTest.supportRestrictedEnum = True
return PostgresConnection(db='test')
***************
*** 26,33 ****
SQLObjectTest.supportDynamic = False
SQLObjectTest.supportAuto = False
return SQLiteConnection('data/sqlite.data')
- databaseName = None
-
supportedDatabases = ['mysql', 'postgres', 'sqlite', 'dbm']
--- 31,37 ----
SQLObjectTest.supportDynamic = False
SQLObjectTest.supportAuto = False
+ SQLObjectTest.supportRestrictedEnum = False
return SQLiteConnection('data/sqlite.data')
supportedDatabases = ['mysql', 'postgres', 'sqlite', 'dbm']
***************
*** 38,41 ****
--- 42,47 ----
debugSQL = 0
+ databaseName = None
+
def setUp(self):
if self.debugSQL:
***************
*** 47,54 ****
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)
--- 53,60 ----
c._connection = __connection__
for c in self.classes + [self]:
! 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)
***************
*** 56,63 ****
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)
--- 62,69 ----
c.dropTable(ifExists=True)
! 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)
***************
*** 80,86 ****
def setDatabaseType(t):
global __connection__
- global databaseName
conn = globals()[t + "Connection"]()
! databaseName = t
__connection__ = conn
--- 86,91 ----
def setDatabaseType(t):
global __connection__
conn = globals()[t + "Connection"]()
! SQLObject.databaseName = t
__connection__ = conn
Index: test.py
===================================================================
RCS file: /cvsroot/sqlobject/SQLObject/tests/test.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** test.py 19 Apr 2003 00:04:08 -0000 1.8
--- test.py 19 Apr 2003 00:54:25 -0000 1.9
***************
*** 32,35 ****
--- 32,64 ----
########################################
+ ## Enum test
+ ########################################
+
+ class Enum1(SQLObject):
+
+ _columns = [
+ EnumCol('l', enumValues=['a', 'bcd', 'e']),
+ ]
+
+ class TestEnum1(SQLObjectTest):
+
+ classes = [Enum1]
+
+ def inserts(self):
+ for l in ['a', 'bcd', 'a', 'e']:
+ Enum1.new(l=l)
+
+ def testBad(self):
+ if self.supportRestrictedEnum:
+ try:
+ v = Enum1.new(l='b')
+ except Exception, e:
+ pass
+ else:
+ print v
+ assert 0, "This should cause an error"
+
+
+ ########################################
## Slicing tests
########################################
|