|
15 | 15 | # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, |
16 | 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 | 20 | import unittest, os, shutil, errno, imp, sys, time, pprint, sets |
21 | 21 |
|
@@ -626,6 +626,41 @@ def testExceptions(self): |
626 | 626 | # invalid boolean value |
627 | 627 | ar(TypeError, self.db.user.set, nid, assignable='true') |
628 | 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) |
| 663 | + |
629 | 664 | def testJournals(self): |
630 | 665 | muid = self.db.user.create(username="mary") |
631 | 666 | self.db.user.create(username="pete") |
@@ -1406,7 +1441,6 @@ def testFilteringSortId(self): |
1406 | 1441 | ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']) |
1407 | 1442 |
|
1408 | 1443 | # XXX add sorting tests for other types |
1409 | | -# XXX test auditors and reactors |
1410 | 1444 |
|
1411 | 1445 | def testImportExport(self): |
1412 | 1446 | # use the filtering setup to create a bunch of items |
|
0 commit comments