|
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.84 2007-03-14 15:23:11 schlatterbeck Exp $ |
| 18 | +# $Id: db_test_base.py,v 1.85 2007-04-11 20:04:06 forsberg Exp $ |
19 | 19 |
|
20 | 20 | import unittest, os, shutil, errno, imp, sys, time, pprint, sets |
21 | 21 |
|
22 | 22 | from roundup.hyperdb import String, Password, Link, Multilink, Date, \ |
23 | 23 | Interval, DatabaseError, Boolean, Number, Node |
24 | | -from roundup import date, password, init, instance, configuration |
| 24 | +from roundup import date, password, init, instance, configuration, support |
25 | 25 |
|
26 | 26 | from mocknull import MockNull |
27 | 27 |
|
@@ -879,6 +879,51 @@ def testForcedReindexing(self): |
879 | 879 | self.assertEquals(self.db.indexer.search(['flebble'], self.db.issue), |
880 | 880 | {'1': {}}) |
881 | 881 |
|
| 882 | + def testIndexingOnImport(self): |
| 883 | + msgcontent = 'Glrk' |
| 884 | + msgid = self.db.msg.import_list(['content'], [repr(msgcontent)]) |
| 885 | + msg_filename = self.db.filename(self.db.msg.classname, msgid, |
| 886 | + create=1) |
| 887 | + support.ensureParentsExist(msg_filename) |
| 888 | + msg_file = open(msg_filename, 'w') |
| 889 | + msg_file.write(msgcontent) |
| 890 | + msg_file.close() |
| 891 | + |
| 892 | + |
| 893 | + filecontent = 'Brrk' |
| 894 | + fileid = self.db.file.import_list(['content'], [repr(filecontent)]) |
| 895 | + file_filename = self.db.filename(self.db.file.classname, fileid, |
| 896 | + create=1) |
| 897 | + support.ensureParentsExist(file_filename) |
| 898 | + file_file = open(file_filename, 'w') |
| 899 | + file_file.write(filecontent) |
| 900 | + file_file.close() |
| 901 | + |
| 902 | + title = 'Bzzt' |
| 903 | + nodeid = self.db.issue.import_list(['title', 'messages', 'files', |
| 904 | + 'spam', |
| 905 | + 'nosy', |
| 906 | + 'superseder'], |
| 907 | + [repr(title), |
| 908 | + repr([msgid]), |
| 909 | + repr([fileid]), |
| 910 | + repr([]), |
| 911 | + repr([]), |
| 912 | + repr([])]) |
| 913 | + self.db.commit() |
| 914 | + |
| 915 | + # Content of title attribute is indexed |
| 916 | + self.assertEquals(self.db.indexer.search([title], self.db.issue), |
| 917 | + {str(nodeid):{}}) |
| 918 | + # Content of message is indexed |
| 919 | + self.assertEquals(self.db.indexer.search([msgcontent], self.db.issue), |
| 920 | + {str(nodeid):{'messages':[str(msgid)]}}) |
| 921 | + # Content of file is indexed |
| 922 | + self.assertEquals(self.db.indexer.search([filecontent], self.db.issue), |
| 923 | + {str(nodeid):{'files':[str(fileid)]}}) |
| 924 | + |
| 925 | + |
| 926 | + |
882 | 927 | # |
883 | 928 | # searching tests follow |
884 | 929 | # |
|
0 commit comments