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.31 2002-07-14 23:17:45 richard Exp $
18+ # $Id: test_db.py,v 1.32 2002-07-18 11:41:10 richard Exp $
1919
2020import unittest , os , shutil , time
2121
2222from roundup .hyperdb import String , Password , Link , Multilink , Date , \
23- Interval , DatabaseError
23+ Interval , DatabaseError , Boolean , Number
2424from roundup import date , password
2525from roundup .indexer import Indexer
2626
2727def setupSchema (db , create , module ):
2828 status = module .Class (db , "status" , name = String ())
2929 status .setkey ("name" )
30- user = module .Class (db , "user" , username = String (), password = Password ())
30+ user = module .Class (db , "user" , username = String (), password = Password (),
31+ assignable = Boolean (), age = Number ())
3132 file = module .FileClass (db , "file" , name = String (), type = String (),
3233 comment = String (indexme = "yes" ))
3334 issue = module .IssueClass (db , "issue" , title = String (indexme = "yes" ),
@@ -72,7 +73,7 @@ def setUp(self):
7273 self .db2 = anydbm .Database (config , 'test' )
7374 setupSchema (self .db2 , 0 , anydbm )
7475
75- def testStringChange (self ):
76+ def xtestStringChange (self ):
7677 self .db .issue .create (title = "spam" , status = '1' )
7778 self .assertEqual (self .db .issue .get ('1' , 'title' ), 'spam' )
7879 self .db .issue .set ('1' , title = 'eggs' )
@@ -87,13 +88,13 @@ def testStringChange(self):
8788 self .db .commit ()
8889 self .assertEqual (self .db .issue .get ('2' , 'title' ), 'ham' )
8990
90- def testLinkChange (self ):
91+ def xtestLinkChange (self ):
9192 self .db .issue .create (title = "spam" , status = '1' )
9293 self .assertEqual (self .db .issue .get ('1' , "status" ), '1' )
9394 self .db .issue .set ('1' , status = '2' )
9495 self .assertEqual (self .db .issue .get ('1' , "status" ), '2' )
9596
96- def testDateChange (self ):
97+ def xtestDateChange (self ):
9798 self .db .issue .create (title = "spam" , status = '1' )
9899 a = self .db .issue .get ('1' , "deadline" )
99100 self .db .issue .set ('1' , deadline = date .Date ())
@@ -103,13 +104,25 @@ def testDateChange(self):
103104 self .assertNotEqual (b , date .Date ('1970-1-1 00:00:00' ))
104105 self .db .issue .set ('1' , deadline = date .Date ())
105106
106- def testIntervalChange (self ):
107+ def xtestIntervalChange (self ):
107108 self .db .issue .create (title = "spam" , status = '1' )
108109 a = self .db .issue .get ('1' , "foo" )
109110 self .db .issue .set ('1' , foo = date .Interval ('-1d' ))
110111 self .assertNotEqual (self .db .issue .get ('1' , "foo" ), a )
111112
112- def testNewProperty (self ):
113+ def testBooleanChange (self ):
114+ self .db .user .create (username = 'foo' , assignable = '1' )
115+ a = self .db .user .get ('1' , 'assignable' )
116+ self .db .user .set ('1' , assignable = 'false' )
117+ self .assertNotEqual (self .db .user .get ('1' , 'assignable' ), a )
118+ self .db .user .set ('1' , assignable = 'FaLse' )
119+ self .db .user .set ('1' , assignable = 'nO' )
120+ self .db .user .set ('1' , assignable = '0' )
121+ self .db .user .set ('1' , assignable = 'tRuE' )
122+ self .db .user .set ('1' , assignable = 'yEs' )
123+ self .db .user .set ('1' , assignable = '1' )
124+
125+ def xtestNewProperty (self ):
113126 ' make sure a new property is added ok '
114127 self .db .issue .create (title = "spam" , status = '1' )
115128 self .db .issue .addprop (fixer = Link ("user" ))
@@ -121,7 +134,7 @@ def testNewProperty(self):
121134 'superseder' , 'title' ])
122135 self .assertEqual (self .db .issue .get ('1' , "fixer" ), None )
123136
124- def testRetire (self ):
137+ def xtestRetire (self ):
125138 self .db .issue .create (title = "spam" , status = '1' )
126139 b = self .db .status .get ('1' , 'name' )
127140 a = self .db .status .list ()
@@ -134,7 +147,7 @@ def testRetire(self):
134147 self .assertEqual (self .db .status .get ('1' , 'name' ), b )
135148 self .assertNotEqual (a , self .db .status .list ())
136149
137- def testSerialisation (self ):
150+ def xtestSerialisation (self ):
138151 self .db .issue .create (title = "spam" , status = '1' ,
139152 deadline = date .Date (), foo = date .Interval ('-1d' ))
140153 self .db .commit ()
@@ -145,7 +158,7 @@ def testSerialisation(self):
145158 self .db .commit ()
146159 assert isinstance (self .db .user .get ('1' , 'password' ), password .Password )
147160
148- def testTransactions (self ):
161+ def xtestTransactions (self ):
149162 # remember the number of items we started
150163 num_issues = len (self .db .issue .list ())
151164 num_files = self .db .numfiles ()
@@ -173,7 +186,7 @@ def testTransactions(self):
173186 self .assertNotEqual (num_files , self .db .numfiles ())
174187 self .assertEqual (num_files2 , self .db .numfiles ())
175188
176- def testExceptions (self ):
189+ def xtestExceptions (self ):
177190 # this tests the exceptions that should be raised
178191 ar = self .assertRaises
179192
@@ -243,7 +256,7 @@ def testExceptions(self):
243256 ar (IndexError , self .db .issue .set , '6' , title = 'foo' , status = '1' ,
244257 nosy = ['10' ])
245258
246- def testJournals (self ):
259+ def xtestJournals (self ):
247260 self .db .issue .addprop (fixer = Link ("user" , do_journal = 'yes' ))
248261 self .db .user .create (username = "mary" )
249262 self .db .user .create (username = "pete" )
@@ -312,7 +325,7 @@ def testJournals(self):
312325 # see if the change was journalled
313326 self .assertNotEqual (date_stamp , date_stamp2 )
314327
315- def testPack (self ):
328+ def xtestPack (self ):
316329 self .db .issue .create (title = "spam" , status = '1' )
317330 self .db .commit ()
318331 self .db .issue .set ('1' , status = '2' )
@@ -324,12 +337,12 @@ def testPack(self):
324337 journal = self .db .getjournal ('issue' , '1' )
325338 self .assertEqual (2 , len (journal ))
326339
327- def testIDGeneration (self ):
340+ def xtestIDGeneration (self ):
328341 id1 = self .db .issue .create (title = "spam" , status = '1' )
329342 id2 = self .db2 .issue .create (title = "eggs" , status = '2' )
330343 self .assertNotEqual (id1 , id2 )
331344
332- def testSearching (self ):
345+ def xtestSearching (self ):
333346 self .db .file .create (content = 'hello' , type = "text/plain" )
334347 self .db .file .create (content = 'world' , type = "text/frozz" ,
335348 comment = 'blah blah' )
@@ -344,7 +357,7 @@ def testSearching(self):
344357 self .assertEquals (self .db .indexer .search (['flebble' ], self .db .issue ),
345358 {'2' : {}, '1' : {}})
346359
347- def testReindexing (self ):
360+ def xtestReindexing (self ):
348361 self .db .issue .create (title = "frooz" )
349362 self .db .commit ()
350363 self .assertEquals (self .db .indexer .search (['frooz' ], self .db .issue ),
@@ -355,7 +368,7 @@ def testReindexing(self):
355368 {'1' : {}})
356369 self .assertEquals (self .db .indexer .search (['frooz' ], self .db .issue ), {})
357370
358- def testForcedReindexing (self ):
371+ def xtestForcedReindexing (self ):
359372 self .db .issue .create (title = "flebble frooz" )
360373 self .db .commit ()
361374 self .assertEquals (self .db .indexer .search (['flebble' ], self .db .issue ),
@@ -381,7 +394,7 @@ def setUp(self):
381394 self .db2 = anydbm .Database (config , 'test' )
382395 setupSchema (self .db2 , 0 , anydbm )
383396
384- def testExceptions (self ):
397+ def xtestExceptions (self ):
385398 ' make sure exceptions are raised on writes to a read-only db '
386399 # this tests the exceptions that should be raised
387400 ar = self .assertRaises
@@ -460,7 +473,7 @@ def setUp(self):
460473 self .db2 = metakit .Database (config , 'test' )
461474 setupSchema (self .db2 , 0 , metakit )
462475
463- def testTransactions (self ):
476+ def xtestTransactions (self ):
464477 # remember the number of items we started
465478 num_issues = len (self .db .issue .list ())
466479 self .db .issue .create (title = "don't commit me!" , status = '1' )
@@ -506,7 +519,7 @@ def suite():
506519 unittest .makeSuite (anydbmDBTestCase , 'test' ),
507520 unittest .makeSuite (anydbmReadOnlyDBTestCase , 'test' )
508521 ]
509- # return unittest.TestSuite(l)
522+ return unittest .TestSuite (l )
510523
511524 try :
512525 import bsddb
@@ -533,6 +546,9 @@ def suite():
533546
534547#
535548# $Log: not supported by cvs2svn $
549+ # Revision 1.31 2002/07/14 23:17:45 richard
550+ # minor change to make testing easier
551+ #
536552# Revision 1.30 2002/07/14 06:06:34 richard
537553# Did some old TODOs
538554#
0 commit comments