Mercurial > p > roundup > code
comparison test/db_test_base.py @ 3997:edbb89730dc2
Fix indexer handling of indexed Link properties
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Mon, 18 Aug 2008 06:57:49 +0000 |
| parents | 6bd3df4356b1 |
| children | 953234004ba2 |
comparison
equal
deleted
inserted
replaced
| 3996:ba4452e91a28 | 3997:edbb89730dc2 |
|---|---|
| 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.98 2008-08-18 06:41:32 richard Exp $ | 18 # $Id: db_test_base.py,v 1.99 2008-08-18 06:57:49 richard Exp $ |
| 19 | 19 |
| 20 import unittest, os, shutil, errno, imp, sys, time, pprint, sets, base64, os.path | 20 import unittest, os, shutil, errno, imp, sys, time, pprint, sets, base64, os.path |
| 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 |
| 79 comment=String(indexme="yes"), fooz=Password()) | 79 comment=String(indexme="yes"), fooz=Password()) |
| 80 file_nidx = module.FileClass(db, "file_nidx", content=String(indexme='no')) | 80 file_nidx = module.FileClass(db, "file_nidx", content=String(indexme='no')) |
| 81 issue = module.IssueClass(db, "issue", title=String(indexme="yes"), | 81 issue = module.IssueClass(db, "issue", title=String(indexme="yes"), |
| 82 status=Link("status"), nosy=Multilink("user"), deadline=Date(), | 82 status=Link("status"), nosy=Multilink("user"), deadline=Date(), |
| 83 foo=Interval(), files=Multilink("file"), assignedto=Link('user'), | 83 foo=Interval(), files=Multilink("file"), assignedto=Link('user'), |
| 84 priority=Link('priority'), spam=Multilink('msg')) | 84 priority=Link('priority'), spam=Multilink('msg'), |
| 85 feedback=Link('msg')) | |
| 85 stuff = module.Class(db, "stuff", stuff=String()) | 86 stuff = module.Class(db, "stuff", stuff=String()) |
| 86 session = module.Class(db, 'session', title=String()) | 87 session = module.Class(db, 'session', title=String()) |
| 87 msg = module.FileClass(db, "msg", date=Date(), | 88 msg = module.FileClass(db, "msg", date=Date(), |
| 88 author=Link("user", do_journal='no'), | 89 author=Link("user", do_journal='no'), |
| 89 files=Multilink('file'), inreplyto=String(), | 90 files=Multilink('file'), inreplyto=String(), |
| 855 self.assertEquals(self.db.indexer.search(['frooz', 'flebble'], | 856 self.assertEquals(self.db.indexer.search(['frooz', 'flebble'], |
| 856 self.db.issue), {i2: {}}) | 857 self.db.issue), {i2: {}}) |
| 857 | 858 |
| 858 # unindexed stopword | 859 # unindexed stopword |
| 859 self.assertEquals(self.db.indexer.search(['the'], self.db.issue), {}) | 860 self.assertEquals(self.db.indexer.search(['the'], self.db.issue), {}) |
| 861 | |
| 862 def testIndexerSearchingLink(self): | |
| 863 m1 = self.db.msg.create(content="one two") | |
| 864 i1 = self.db.issue.create(messages=[m1]) | |
| 865 m2 = self.db.msg.create(content="two three") | |
| 866 i2 = self.db.issue.create(feedback=m2) | |
| 867 self.db.commit() | |
| 868 self.assertEquals(self.db.indexer.search(['two'], self.db.issue), | |
| 869 {i1: {'messages': [m1]}, i2: {'feedback': [m2]}}) | |
| 860 | 870 |
| 861 def testIndexerSearchMulti(self): | 871 def testIndexerSearchMulti(self): |
| 862 m1 = self.db.msg.create(content="one two") | 872 m1 = self.db.msg.create(content="one two") |
| 863 m2 = self.db.msg.create(content="two three") | 873 m2 = self.db.msg.create(content="two three") |
| 864 i1 = self.db.issue.create(messages=[m1]) | 874 i1 = self.db.issue.create(messages=[m1]) |
| 1723 self.db.post_init() | 1733 self.db.post_init() |
| 1724 props = self.db.issue.getprops() | 1734 props = self.db.issue.getprops() |
| 1725 keys = props.keys() | 1735 keys = props.keys() |
| 1726 keys.sort() | 1736 keys.sort() |
| 1727 self.assertEqual(keys, ['activity', 'actor', 'assignedto', 'creation', | 1737 self.assertEqual(keys, ['activity', 'actor', 'assignedto', 'creation', |
| 1728 'creator', 'deadline', 'files', 'fixer', 'foo', 'id', 'messages', | 1738 'creator', 'deadline', 'feedback', 'files', 'fixer', 'foo', 'id', 'messages', |
| 1729 'nosy', 'priority', 'spam', 'status', 'superseder', 'title']) | 1739 'nosy', 'priority', 'spam', 'status', 'superseder', 'title']) |
| 1730 self.assertEqual(self.db.issue.get('1', "fixer"), None) | 1740 self.assertEqual(self.db.issue.get('1', "fixer"), None) |
| 1731 | 1741 |
| 1732 def testRemoveProperty(self): | 1742 def testRemoveProperty(self): |
| 1733 self.db.issue.create(title="spam", status='1') | 1743 self.db.issue.create(title="spam", status='1') |
| 1737 self.db.post_init() | 1747 self.db.post_init() |
| 1738 props = self.db.issue.getprops() | 1748 props = self.db.issue.getprops() |
| 1739 keys = props.keys() | 1749 keys = props.keys() |
| 1740 keys.sort() | 1750 keys.sort() |
| 1741 self.assertEqual(keys, ['activity', 'actor', 'assignedto', 'creation', | 1751 self.assertEqual(keys, ['activity', 'actor', 'assignedto', 'creation', |
| 1742 'creator', 'deadline', 'files', 'foo', 'id', 'messages', | 1752 'creator', 'deadline', 'feedback', 'files', 'foo', 'id', 'messages', |
| 1743 'nosy', 'priority', 'spam', 'status', 'superseder']) | 1753 'nosy', 'priority', 'spam', 'status', 'superseder']) |
| 1744 self.assertEqual(self.db.issue.list(), ['1']) | 1754 self.assertEqual(self.db.issue.list(), ['1']) |
| 1745 | 1755 |
| 1746 def testAddRemoveProperty(self): | 1756 def testAddRemoveProperty(self): |
| 1747 self.db.issue.create(title="spam", status='1') | 1757 self.db.issue.create(title="spam", status='1') |
