1515# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717#
18- # $Id: test_db.py,v 1.20 2002-04-03 05:54:31 richard Exp $
18+ # $Id: test_db.py,v 1.21 2002-04-15 23:25:15 richard Exp $
1919
2020import unittest , os , shutil
2121
@@ -66,6 +66,8 @@ def setUp(self):
6666 os .makedirs (config .DATABASE + '/files' )
6767 self .db = anydbm .Database (config , 'test' )
6868 setupSchema (self .db , 1 )
69+ self .db2 = anydbm .Database (config , 'test' )
70+ setupSchema (self .db2 , 0 )
6971
7072 def testChanges (self ):
7173 self .db .issue .create (title = "spam" , status = '1' )
@@ -140,8 +142,6 @@ def testTransactions(self):
140142 self .db .rollback ()
141143 self .assertNotEqual (num_files , self .db .numfiles ())
142144 self .assertEqual (num_files2 , self .db .numfiles ())
143-
144-
145145
146146 def testExceptions (self ):
147147 # this tests the exceptions that should be raised
@@ -192,17 +192,17 @@ def testExceptions(self):
192192 # set up a valid issue for me to work on
193193 self .db .issue .create (title = "spam" , status = '1' )
194194 # invalid link index
195- ar (IndexError , self .db .issue .set , '1 ' , title = 'foo' , status = 'bar' )
195+ ar (IndexError , self .db .issue .set , '6 ' , title = 'foo' , status = 'bar' )
196196 # invalid link value
197- ar (ValueError , self .db .issue .set , '1 ' , title = 'foo' , status = 1 )
197+ ar (ValueError , self .db .issue .set , '6 ' , title = 'foo' , status = 1 )
198198 # invalid multilink type
199- ar (TypeError , self .db .issue .set , '1 ' , title = 'foo' , status = '1' ,
199+ ar (TypeError , self .db .issue .set , '6 ' , title = 'foo' , status = '1' ,
200200 nosy = 'hello' )
201201 # invalid multilink index type
202- ar (ValueError , self .db .issue .set , '1 ' , title = 'foo' , status = '1' ,
202+ ar (ValueError , self .db .issue .set , '6 ' , title = 'foo' , status = '1' ,
203203 nosy = [1 ])
204204 # invalid multilink index
205- ar (IndexError , self .db .issue .set , '1 ' , title = 'foo' , status = '1' ,
205+ ar (IndexError , self .db .issue .set , '6 ' , title = 'foo' , status = '1' ,
206206 nosy = ['10' ])
207207
208208 def testJournals (self ):
@@ -269,6 +269,11 @@ def testPack(self):
269269 def testRetire (self ):
270270 pass
271271
272+ def testIDGeneration (self ):
273+ id1 = self .db .issue .create (title = "spam" , status = '1' )
274+ id2 = self .db2 .issue .create (title = "eggs" , status = '2' )
275+ self .assertNotEqual (id1 , id2 )
276+
272277
273278class anydbmReadOnlyDBTestCase (MyTestCase ):
274279 def setUp (self ):
@@ -281,6 +286,8 @@ def setUp(self):
281286 setupSchema (db , 1 )
282287 self .db = anydbm .Database (config )
283288 setupSchema (self .db , 0 )
289+ self .db2 = anydbm .Database (config , 'test' )
290+ setupSchema (self .db2 , 0 )
284291
285292 def testExceptions (self ):
286293 # this tests the exceptions that should be raised
@@ -301,6 +308,8 @@ def setUp(self):
301308 os .makedirs (config .DATABASE + '/files' )
302309 self .db = bsddb .Database (config , 'test' )
303310 setupSchema (self .db , 1 )
311+ self .db2 = bsddb .Database (config , 'test' )
312+ setupSchema (self .db2 , 0 )
304313
305314class bsddbReadOnlyDBTestCase (anydbmReadOnlyDBTestCase ):
306315 def setUp (self ):
@@ -313,6 +322,8 @@ def setUp(self):
313322 setupSchema (db , 1 )
314323 self .db = bsddb .Database (config )
315324 setupSchema (self .db , 0 )
325+ self .db2 = bsddb .Database (config , 'test' )
326+ setupSchema (self .db2 , 0 )
316327
317328
318329class bsddb3DBTestCase (anydbmDBTestCase ):
@@ -324,6 +335,8 @@ def setUp(self):
324335 os .makedirs (config .DATABASE + '/files' )
325336 self .db = bsddb3 .Database (config , 'test' )
326337 setupSchema (self .db , 1 )
338+ self .db2 = bsddb3 .Database (config , 'test' )
339+ setupSchema (self .db2 , 0 )
327340
328341class bsddb3ReadOnlyDBTestCase (anydbmReadOnlyDBTestCase ):
329342 def setUp (self ):
@@ -336,6 +349,8 @@ def setUp(self):
336349 setupSchema (db , 1 )
337350 self .db = bsddb3 .Database (config )
338351 setupSchema (self .db , 0 )
352+ self .db2 = bsddb3 .Database (config , 'test' )
353+ setupSchema (self .db2 , 0 )
339354
340355
341356def suite ():
@@ -362,6 +377,14 @@ def suite():
362377
363378#
364379# $Log: not supported by cvs2svn $
380+ # Revision 1.20 2002/04/03 05:54:31 richard
381+ # Fixed serialisation problem by moving the serialisation step out of the
382+ # hyperdb.Class (get, set) into the hyperdb.Database.
383+ #
384+ # Also fixed htmltemplate after the showid changes I made yesterday.
385+ #
386+ # Unit tests for all of the above written.
387+ #
365388# Revision 1.19 2002/02/25 14:34:31 grubert
366389# . use blobfiles in back_anydbm which is used in back_bsddb.
367390# change test_db as dirlist does not work for subdirectories.
0 commit comments