comparison test/test_db.py @ 1178:18bb36e4f62f

Remove some assumptions about what idi numbers will be created.
author Gordon B. McMillan <gmcm@users.sourceforge.net>
date Fri, 20 Sep 2002 19:26:28 +0000
parents bd3b57859c37
children 08a13a84ed43
comparison
equal deleted inserted replaced
1177:24a1a5de1203 1178:18bb36e4f62f
13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" 14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS"
15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, 15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
17 # 17 #
18 # $Id: test_db.py,v 1.52 2002-09-20 05:08:00 richard Exp $ 18 # $Id: test_db.py,v 1.53 2002-09-20 19:26:28 gmcm Exp $
19 19
20 import unittest, os, shutil, time 20 import unittest, os, shutil, time
21 21
22 from roundup.hyperdb import String, Password, Link, Multilink, Date, \ 22 from roundup.hyperdb import String, Password, Link, Multilink, Date, \
23 Interval, DatabaseError, Boolean, Number 23 Interval, DatabaseError, Boolean, Number
312 312
313 # 313 #
314 # class get 314 # class get
315 # 315 #
316 # invalid node id 316 # invalid node id
317 ar(IndexError, self.db.issue.get, '1', 'title') 317 ar(IndexError, self.db.issue.get, '99', 'title')
318 # invalid property name 318 # invalid property name
319 ar(KeyError, self.db.status.get, '2', 'foo') 319 ar(KeyError, self.db.status.get, '2', 'foo')
320 320
321 # 321 #
322 # class set 322 # class set
323 # 323 #
324 # invalid node id 324 # invalid node id
325 ar(IndexError, self.db.issue.set, '1', title='foo') 325 ar(IndexError, self.db.issue.set, '99', title='foo')
326 # invalid property name 326 # invalid property name
327 ar(KeyError, self.db.status.set, '1', foo='foo') 327 ar(KeyError, self.db.status.set, '1', foo='foo')
328 # string property 328 # string property
329 ar(TypeError, self.db.status.set, '1', name=1) 329 ar(TypeError, self.db.status.set, '1', name=1)
330 # key name clash 330 # key name clash
331 ar(ValueError, self.db.status.set, '2', name='unread') 331 ar(ValueError, self.db.status.set, '2', name='unread')
332 # set up a valid issue for me to work on 332 # set up a valid issue for me to work on
333 self.db.issue.create(title="spam", status='1') 333 id = self.db.issue.create(title="spam", status='1')
334 # invalid link index 334 # invalid link index
335 ar(IndexError, self.db.issue.set, '6', title='foo', status='bar') 335 ar(IndexError, self.db.issue.set, id, title='foo', status='bar')
336 # invalid link value 336 # invalid link value
337 ar(ValueError, self.db.issue.set, '6', title='foo', status=1) 337 ar(ValueError, self.db.issue.set, id, title='foo', status=1)
338 # invalid multilink type 338 # invalid multilink type
339 ar(TypeError, self.db.issue.set, '6', title='foo', status='1', 339 ar(TypeError, self.db.issue.set, id, title='foo', status='1',
340 nosy='hello') 340 nosy='hello')
341 # invalid multilink index type 341 # invalid multilink index type
342 ar(ValueError, self.db.issue.set, '6', title='foo', status='1', 342 ar(ValueError, self.db.issue.set, id, title='foo', status='1',
343 nosy=[1]) 343 nosy=[1])
344 # invalid multilink index 344 # invalid multilink index
345 ar(IndexError, self.db.issue.set, '6', title='foo', status='1', 345 ar(IndexError, self.db.issue.set, id, title='foo', status='1',
346 nosy=['10']) 346 nosy=['10'])
347 # invalid number value 347 # invalid number value
348 ar(TypeError, self.db.user.create, username='foo', age='a') 348 ar(TypeError, self.db.user.create, username='foo', age='a')
349 # invalid boolean value 349 # invalid boolean value
350 ar(TypeError, self.db.user.create, username='foo', assignable='true') 350 ar(TypeError, self.db.user.create, username='foo', assignable='true')
420 (x, date_stamp2, x, x, x) = entry 420 (x, date_stamp2, x, x, x) = entry
421 # see if the change was journalled 421 # see if the change was journalled
422 self.assertNotEqual(date_stamp, date_stamp2) 422 self.assertNotEqual(date_stamp, date_stamp2)
423 423
424 def testPack(self): 424 def testPack(self):
425 self.db.issue.create(title="spam", status='1') 425 id = self.db.issue.create(title="spam", status='1')
426 self.db.commit() 426 self.db.commit()
427 self.db.issue.set('1', status='2') 427 self.db.issue.set(id, status='2')
428 self.db.commit() 428 self.db.commit()
429 429
430 # sleep for at least a second, then get a date to pack at 430 # sleep for at least a second, then get a date to pack at
431 time.sleep(1) 431 time.sleep(1)
432 pack_before = date.Date('.') 432 pack_before = date.Date('.')
433 time.sleep(1)
433 434
434 # one more entry 435 # one more entry
435 self.db.issue.set('1', status='3') 436 self.db.issue.set(id, status='3')
436 self.db.commit() 437 self.db.commit()
437 438
438 # pack 439 # pack
439 self.db.pack(pack_before) 440 self.db.pack(pack_before)
440 journal = self.db.getjournal('issue', '1') 441 journal = self.db.getjournal('issue', id)
441 442
442 # we should have the create and last set entries now 443 # we should have the create and last set entries now
443 self.assertEqual(2, len(journal)) 444 self.assertEqual(2, len(journal))
444 445
445 def testIDGeneration(self): 446 def testIDGeneration(self):

Roundup Issue Tracker: http://roundup-tracker.org/