Changeset 2640
- Timestamp:
- 01/10/2007 10:05:39 AM (2 years ago)
- Files:
-
- branches/paul_sandbox/dabo/biz/test/test_dBizobj.py (modified) (3 diffs)
- branches/paul_sandbox/dabo/db/dCursorMixin.py (modified) (1 diff)
- branches/paul_sandbox/dabo/db/test/test_dCursorMixin.py (modified) (8 diffs)
- trunk/dabo/biz/test/test_dBizobj.py (modified) (3 diffs)
- trunk/dabo/db/test/test_dCursorMixin.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/paul_sandbox/dabo/biz/test/test_dBizobj.py
r2637 r2640 2 2 import dabo 3 3 from dabo.lib import getRandomUUID 4 5 6 # Testing anything other than sqlite requires network access. So set these 7 # flags so that only the db's you want to test against are True. 8 test_sqlite = True 9 test_mysql = True 10 11 if test_sqlite: 12 sqlite_unittest = unittest.TestCase 13 else: 14 sqlite_unittest = object 15 16 if test_mysql: 17 mysql_unittest = unittest.TestCase 18 else: 19 mysql_unittest = object 4 20 5 21 … … 177 193 178 194 179 class Test_dBizobj_sqlite(Test_dBizobj, unittest.TestCase):195 class Test_dBizobj_sqlite(Test_dBizobj, sqlite_unittest): 180 196 def setUp(self): 181 197 con = dabo.db.dConnection(DbType="SQLite", Database=":memory:") … … 194 210 195 211 196 class Test_dBizobj_mysql(Test_dBizobj ):212 class Test_dBizobj_mysql(Test_dBizobj, mysql_unittest): 197 213 def setUp(self): 198 214 con = dabo.db.dConnection(DbType="MySQL", User="dabo_unittest", branches/paul_sandbox/dabo/db/dCursorMixin.py
r2621 r2640 628 628 629 629 memento = self._mementos.get(rec[self.KeyField], None) 630 new_rec = self._newRecords. get(rec[self.KeyField], None)631 632 return not (memento is None and n ew_rec is None)630 new_rec = self._newRecords.has_key(rec[self.KeyField]) 631 632 return not (memento is None and not new_rec) 633 633 634 634 branches/paul_sandbox/dabo/db/test/test_dCursorMixin.py
r2634 r2640 2 2 import dabo 3 3 from dabo.lib import getRandomUUID 4 5 6 # Testing anything other than sqlite requires network access. So set these 7 # flags so that only the db's you want to test against are True. 8 test_sqlite = True 9 test_mysql = True 10 11 if test_sqlite: 12 sqlite_unittest = unittest.TestCase 13 else: 14 sqlite_unittest = object 15 16 if test_mysql: 17 mysql_unittest = unittest.TestCase 18 else: 19 mysql_unittest = object 4 20 5 21 … … 164 180 self.assertEqual(cur._mementos, {cur.Record.pk: {"cField": priorVal}}) 165 181 self.assertEqual(cur.isChanged(), True) 182 self.assertEqual(cur.isChanged(allRows=False), True) 166 183 167 184 # Change it back: … … 169 186 self.assertEqual(cur._mementos, {}) 170 187 self.assertEqual(cur.isChanged(), False) 188 self.assertEqual(cur.isChanged(allRows=False), False) 171 189 172 190 # Make a change that is different and cancel: … … 175 193 self.assertEqual(cur._mementos, {}) 176 194 self.assertEqual(cur.isChanged(), False) 195 self.assertEqual(cur.isChanged(allRows=False), False) 177 196 178 197 # Add a record: … … 187 206 self.assertEqual(cur._newRecords, {"-1-dabotmp": None}) 188 207 self.assertEqual(cur.isChanged(), True) 208 self.assertEqual(cur.isChanged(allRows=False), True) 189 209 self.assertEqual(cur.Record.pk, "-1-dabotmp") 190 210 self.assertEqual(cur.Record.cField, "") … … 197 217 self.assertEqual(cur._newRecords, {}) 198 218 self.assertEqual(cur.isChanged(), False) 219 self.assertEqual(cur.isChanged(allRows=False), False) 199 220 self.assertEqual(cur.Record.pk, 4) 200 221 … … 205 226 206 227 207 class Test_dCursorMixin_sqlite(Test_dCursorMixin, unittest.TestCase):228 class Test_dCursorMixin_sqlite(Test_dCursorMixin, sqlite_unittest): 208 229 def setUp(self): 209 230 con = dabo.db.dConnection(DbType="SQLite", Database=":memory:") … … 222 243 223 244 224 class Test_dCursorMixin_mysql(Test_dCursorMixin, unittest.TestCase):245 class Test_dCursorMixin_mysql(Test_dCursorMixin, mysql_unittest): 225 246 def setUp(self): 226 247 con = dabo.db.dConnection(DbType="MySQL", User="dabo_unittest", trunk/dabo/biz/test/test_dBizobj.py
r2637 r2640 2 2 import dabo 3 3 from dabo.lib import getRandomUUID 4 5 6 # Testing anything other than sqlite requires network access. So set these 7 # flags so that only the db's you want to test against are True. 8 test_sqlite = True 9 test_mysql = True 10 11 if test_sqlite: 12 sqlite_unittest = unittest.TestCase 13 else: 14 sqlite_unittest = object 15 16 if test_mysql: 17 mysql_unittest = unittest.TestCase 18 else: 19 mysql_unittest = object 4 20 5 21 … … 123 139 124 140 125 class Test_dBizobj_sqlite(Test_dBizobj, unittest.TestCase):141 class Test_dBizobj_sqlite(Test_dBizobj, sqlite_unittest): 126 142 def setUp(self): 127 143 con = dabo.db.dConnection(DbType="SQLite", Database=":memory:") … … 140 156 141 157 142 class Test_dBizobj_mysql(Test_dBizobj ):158 class Test_dBizobj_mysql(Test_dBizobj, mysql_unittest): 143 159 def setUp(self): 144 160 con = dabo.db.dConnection(DbType="MySQL", User="dabo_unittest", trunk/dabo/db/test/test_dCursorMixin.py
r2611 r2640 2 2 import dabo 3 3 4 5 # Testing anything other than sqlite requires network access. So set these 6 # flags so that only the db's you want to test against are True. 7 test_sqlite = True 8 test_mysql = True 9 10 if test_sqlite: 11 sqlite_unittest = unittest.TestCase 12 else: 13 sqlite_unittest = object 14 15 if test_mysql: 16 mysql_unittest = unittest.TestCase 17 else: 18 mysql_unittest = object 4 19 5 20 … … 28 43 29 44 30 class Test_dCursorMixin_sqlite(Test_dCursorMixin, unittest.TestCase):45 class Test_dCursorMixin_sqlite(Test_dCursorMixin, sqlite_unittest): 31 46 def setUp(self): 32 47 con = dabo.db.dConnection(DbType="SQLite", Database=":memory:") … … 47 62 self.cur = None 48 63 64 class Test_dCursorMixin_mysql(Test_dCursorMixin, mysql_unittest): 65 def setUp(self): 66 con = dabo.db.dConnection(DbType="MySQL", User="dabo_unittest", 67 password="T30T35DB4K30Z45I67N60", Database="dabo_unittest", 68 Host="paulmcnett.com") 69 self.cur = con.getDaboCursor() 70 super(Test_dCursorMixin_mysql, self).setUp() 71 72 def tearDown(self): 73 self.cur.execute("drop table %s" % self.temp_table_name) 74 super(Test_dCursorMixin_mysql, self).tearDown() 75 76 def createSchema(self): 77 cur = self.cur 78 cur.execute(""" 79 create table %s (pk INTEGER PRIMARY KEY AUTO_INCREMENT, cField CHAR (32), iField INT, nField DECIMAL (8,2)) 80 """ % self.temp_table_name) 81 cur.execute(""" 82 insert into %s (cField, iField, nField) values ("Paul Keith McNett", 23, 23.23) 83 """ % self.temp_table_name) 84 cur.execute(""" 85 insert into %s (cField, iField, nField) values ("Edward Leafe", 42, 42.42) 86 """ % self.temp_table_name) 87 cur.execute(""" 88 insert into %s (cField, iField, nField) values ("Carl Karsten", 10223, 23032.76) 89 """ % self.temp_table_name) 90 91 49 92 if __name__ == "__main__": 50 93 unittest.main()
