|
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.13 2004-01-20 03:58:38 richard Exp $ |
| 18 | +# $Id: db_test_base.py,v 1.14 2004-01-20 05:55:51 richard Exp $ |
19 | 19 |
|
20 | 20 | import unittest, os, shutil, errno, imp, sys, time, pprint |
21 | 21 |
|
@@ -621,54 +621,88 @@ def testForcedReindexing(self): |
621 | 621 | # |
622 | 622 | # searching tests follow |
623 | 623 | # |
624 | | - def testFind(self): |
| 624 | + def testFindIncorrectProperty(self): |
625 | 625 | self.assertRaises(TypeError, self.db.issue.find, title='fubar') |
626 | 626 |
|
627 | | - self.db.user.create(username='test') |
628 | | - ids = [] |
629 | | - ids.append(self.db.issue.create(status="1", nosy=['1'])) |
630 | | - oddid = self.db.issue.create(status="2", nosy=['2'], assignedto='2') |
631 | | - ids.append(self.db.issue.create(status="1", nosy=['1','2'])) |
632 | | - self.db.issue.create(status="3", nosy=['1'], assignedto='1') |
633 | | - ids.sort() |
634 | | - |
635 | | - # should match first and third |
| 627 | + def _find_test_setup(self): |
| 628 | + self.db.file.create(content='') |
| 629 | + self.db.file.create(content='') |
| 630 | + self.db.user.create(username='') |
| 631 | + one = self.db.issue.create(status="1", nosy=['1']) |
| 632 | + two = self.db.issue.create(status="2", nosy=['2'], files=['1'], |
| 633 | + assignedto='2') |
| 634 | + three = self.db.issue.create(status="1", nosy=['1','2']) |
| 635 | + four = self.db.issue.create(status="3", assignedto='1', |
| 636 | + files=['1','2']) |
| 637 | + return one, two, three, four |
| 638 | + |
| 639 | + def testFindLink(self): |
| 640 | + one, two, three, four = self._find_test_setup() |
636 | 641 | got = self.db.issue.find(status='1') |
637 | 642 | got.sort() |
638 | | - self.assertEqual(got, ids) |
| 643 | + self.assertEqual(got, [one, three]) |
639 | 644 | got = self.db.issue.find(status={'1':1}) |
640 | 645 | got.sort() |
641 | | - self.assertEqual(got, ids) |
| 646 | + self.assertEqual(got, [one, three]) |
642 | 647 |
|
643 | | - # none |
| 648 | + def testFindLinkFail(self): |
| 649 | + self._find_test_setup() |
644 | 650 | self.assertEqual(self.db.issue.find(status='4'), []) |
645 | 651 | self.assertEqual(self.db.issue.find(status={'4':1}), []) |
646 | 652 |
|
647 | | - # should match first and third |
| 653 | + def testFindLinkUnset(self): |
| 654 | + one, two, three, four = self._find_test_setup() |
648 | 655 | got = self.db.issue.find(assignedto=None) |
649 | 656 | got.sort() |
650 | | - self.assertEqual(got, ids) |
| 657 | + self.assertEqual(got, [one, three]) |
651 | 658 | got = self.db.issue.find(assignedto={None:1}) |
652 | 659 | got.sort() |
653 | | - self.assertEqual(got, ids) |
| 660 | + self.assertEqual(got, [one, three]) |
| 661 | + |
| 662 | + def testFindMultilink(self): |
| 663 | + one, two, three, four = self._find_test_setup() |
| 664 | + got = self.db.issue.find(nosy='2') |
| 665 | + got.sort() |
| 666 | + self.assertEqual(got, [two, three]) |
| 667 | + got = self.db.issue.find(nosy={'2':1}) |
| 668 | + got.sort() |
| 669 | + self.assertEqual(got, [two, three]) |
| 670 | + got = self.db.issue.find(nosy={'2':1}, files={}) |
| 671 | + got.sort() |
| 672 | + self.assertEqual(got, [two, three]) |
654 | 673 |
|
655 | | - # should match first three |
| 674 | + def testFindMultiMultilink(self): |
| 675 | + one, two, three, four = self._find_test_setup() |
| 676 | + got = self.db.issue.find(nosy='2', files='1') |
| 677 | + got.sort() |
| 678 | + self.assertEqual(got, [two, three, four]) |
| 679 | + got = self.db.issue.find(nosy={'2':1}, files={'1':1}) |
| 680 | + got.sort() |
| 681 | + self.assertEqual(got, [two, three, four]) |
| 682 | + |
| 683 | + def testFindMultilinkFail(self): |
| 684 | + self._find_test_setup() |
| 685 | + self.assertEqual(self.db.issue.find(nosy='3'), []) |
| 686 | + self.assertEqual(self.db.issue.find(nosy={'3':1}), []) |
| 687 | + |
| 688 | + def testFindMultilinkUnset(self): |
| 689 | + self._find_test_setup() |
| 690 | + self.assertEqual(self.db.issue.find(nosy={}), []) |
| 691 | + |
| 692 | + def testFindLinkAndMultilink(self): |
| 693 | + one, two, three, four = self._find_test_setup() |
656 | 694 | got = self.db.issue.find(status='1', nosy='2') |
657 | 695 | got.sort() |
658 | | - ids.append(oddid) |
659 | | - ids.sort() |
660 | | - self.assertEqual(got, ids) |
| 696 | + self.assertEqual(got, [one, two, three]) |
661 | 697 | got = self.db.issue.find(status={'1':1}, nosy={'2':1}) |
662 | 698 | got.sort() |
663 | | - self.assertEqual(got, ids) |
664 | | - |
665 | | - # none |
666 | | - self.assertEqual(self.db.issue.find(status='4', nosy='3'), []) |
667 | | - self.assertEqual(self.db.issue.find(status={'4':1}, nosy={'3':1}), []) |
| 699 | + self.assertEqual(got, [one, two, three]) |
668 | 700 |
|
669 | | - # test retiring a node |
670 | | - self.db.issue.retire(ids[0]) |
671 | | - self.assertEqual(len(self.db.issue.find(status='1', nosy='2')), 2) |
| 701 | + def testFindRetired(self): |
| 702 | + one, two, three, four = self._find_test_setup() |
| 703 | + self.assertEqual(len(self.db.issue.find(status='1')), 2) |
| 704 | + self.db.issue.retire(one) |
| 705 | + self.assertEqual(len(self.db.issue.find(status='1')), 1) |
672 | 706 |
|
673 | 707 | def testStringFind(self): |
674 | 708 | self.assertRaises(TypeError, self.db.issue.stringFind, status='1') |
|
0 commit comments