comparison test/db_test_base.py @ 3743:e754cc14e76a

fix unstable ordering of detectors [SF#1585378]
author Richard Jones <richard@users.sourceforge.net>
date Thu, 09 Nov 2006 03:08:22 +0000
parents 8e52157e2073
children 5cde43526788
comparison
equal deleted inserted replaced
3742:a9f6eb633452 3743:e754cc14e76a
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: db_test_base.py,v 1.78 2006-08-30 08:50:44 schlatterbeck Exp $ 18 # $Id: db_test_base.py,v 1.79 2006-11-09 03:08:22 richard Exp $
19 19
20 import unittest, os, shutil, errno, imp, sys, time, pprint, sets 20 import unittest, os, shutil, errno, imp, sys, time, pprint, sets
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, Node 23 Interval, DatabaseError, Boolean, Number, Node
623 nid = self.db.user.create(username='foo3') 623 nid = self.db.user.create(username='foo3')
624 # invalid number value 624 # invalid number value
625 ar(TypeError, self.db.user.set, nid, age='a') 625 ar(TypeError, self.db.user.set, nid, age='a')
626 # invalid boolean value 626 # invalid boolean value
627 ar(TypeError, self.db.user.set, nid, assignable='true') 627 ar(TypeError, self.db.user.set, nid, assignable='true')
628
629 def testAuditors(self):
630 class test:
631 called = False
632 def call(self, *args): self.called = True
633 create = test()
634
635 self.db.user.audit('create', create.call)
636 self.db.user.create(username="mary")
637 self.assertEqual(create.called, True)
638
639 set = test()
640 self.db.user.audit('set', set.call)
641 self.db.user.set('1', username="joe")
642 self.assertEqual(set.called, True)
643
644 retire = test()
645 self.db.user.audit('retire', retire.call)
646 self.db.user.retire('1')
647 self.assertEqual(retire.called, True)
648
649 def testAuditorTwo(self):
650 class test:
651 n = 0
652 def a(self, *args): self.call_a = self.n; self.n += 1
653 def b(self, *args): self.call_b = self.n; self.n += 1
654 def c(self, *args): self.call_c = self.n; self.n += 1
655 test = test()
656 self.db.user.audit('create', test.b, 1)
657 self.db.user.audit('create', test.a, 1)
658 self.db.user.audit('create', test.c, 2)
659 self.db.user.create(username="mary")
660 self.assertEqual(test.call_a, 0)
661 self.assertEqual(test.call_b, 1)
662 self.assertEqual(test.call_c, 2)
628 663
629 def testJournals(self): 664 def testJournals(self):
630 muid = self.db.user.create(username="mary") 665 muid = self.db.user.create(username="mary")
631 self.db.user.create(username="pete") 666 self.db.user.create(username="pete")
632 self.db.issue.create(title="spam", status='1') 667 self.db.issue.create(title="spam", status='1')
1404 ae, filt = self.filteringSetupTransitiveSearch() 1439 ae, filt = self.filteringSetupTransitiveSearch()
1405 ae(self.db.user.filter(None, {}, ('+','id')), 1440 ae(self.db.user.filter(None, {}, ('+','id')),
1406 ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']) 1441 ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10'])
1407 1442
1408 # XXX add sorting tests for other types 1443 # XXX add sorting tests for other types
1409 # XXX test auditors and reactors
1410 1444
1411 def testImportExport(self): 1445 def testImportExport(self):
1412 # use the filtering setup to create a bunch of items 1446 # use the filtering setup to create a bunch of items
1413 ae, filt = self.filteringSetup() 1447 ae, filt = self.filteringSetup()
1414 self.db.user.retire('3') 1448 self.db.user.retire('3')

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