Changeset 2641

Show
Ignore:
Timestamp:
01/10/07 10:22:17 (2 years ago)
Author:
paul
Message:

Fixed up the trunk's version of the dCursorMixin test. I'll eventually
replace this one with the one from my branch, but at least it runs
correctly now after my last commit broke it.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/dabo/db/test/test_dCursorMixin.py

    r2640 r2641  
    11import unittest 
    22import dabo 
     3from dabo.lib import getRandomUUID 
    34 
    45 
     
    2223    def setUp(self): 
    2324        cur = self.cur 
    24         cur.UserSQL = "select * from test" 
     25        self.temp_table_name = "unittest%s" % getRandomUUID().replace("-", "")[-20:] 
     26        self.createSchema() 
     27        cur.UserSQL = "select * from %s" % self.temp_table_name 
    2528        cur.KeyField = "pk" 
    26         cur.Table = "test" 
     29        cur.Table = self.temp_table_name 
    2730        cur.requery() 
    2831 
     
    3740        self.assertEqual(self.cur.Record.cField, "Paul Keith McNett") 
    3841 
    39     def testDataStructure(self): 
     42    def test_DataStructure(self): 
    4043        ds = self.cur.DataStructure 
    41         self.assertEqual(ds[0], ("pk", "I", True, "test", "pk", None)) 
    42         self.assertEqual(ds[1], ("cField", "C", False, "test", "cField", None)) 
     44        self.assertTrue(ds[0] == ("pk", "I", True, self.temp_table_name, "pk", None) 
     45                or ds[0] == ("pk", "G", True, self.temp_table_name, "pk", None)) 
     46        self.assertEqual(ds[1], ("cField", "C", False, self.temp_table_name, "cField", None)) 
     47        self.assertTrue(ds[2] == ("iField", "I", False, self.temp_table_name, "iField", None) 
     48                or ds[2] == ("iField", "G", False, self.temp_table_name, "iField", None)) 
     49        self.assertEqual(ds[3], ("nField", "N", False, self.temp_table_name, "nField", None)) 
    4350 
    4451 
     
    4754        con = dabo.db.dConnection(DbType="SQLite", Database=":memory:") 
    4855        self.cur = con.getDaboCursor() 
    49         self.createSchema() 
    5056        super(Test_dCursorMixin_sqlite, self).setUp() 
    5157 
    5258    def createSchema(self): 
    53         """Creates the test database schema for the tests.""" 
    5459        cur = self.cur 
     60        tableName = self.temp_table_name 
    5561        cur.executescript(""" 
    56 create table test (pk INTEGER PRIMARY KEY AUTOINCREMENT, cField CHAR, iField INT, nField DECIMAL (8,2)); 
    57 insert into test (cField, iField, nField) values ("Paul Keith McNett", 23, 23.23); 
    58 insert into test (cField, iField, nField) values ("Edward Leafe", 42, 42.42); 
    59 insert into test (cField, iField, nField) values ("Carl Karsten", 10223, 23032.76);""") 
     62create table %s (pk INTEGER PRIMARY KEY AUTOINCREMENT, cField CHAR, iField INT, nField DECIMAL (8,2)); 
     63insert into %s (cField, iField, nField) values ("Paul Keith McNett", 23, 23.23); 
     64insert into %s (cField, iField, nField) values ("Edward Leafe", 42, 42.42); 
     65insert into %s (cField, iField, nField) values ("Carl Karsten", 10223, 23032.76); 
     66""" % (tableName, tableName, tableName, tableName, )) 
    6067 
    61     def tearDown(self): 
    62         self.cur = None 
    6368 
    6469class Test_dCursorMixin_mysql(Test_dCursorMixin, mysql_unittest):