comparison test/db_test_base.py @ 3844:cf8b716d9ac2

Fix for [SF#698136] Trouble with full-text indexer, with test.
author Erik Forsberg <forsberg@users.sourceforge.net>
date Wed, 11 Apr 2007 20:04:06 +0000
parents bf2e9535da00
children 16faac822fe5
comparison
equal deleted inserted replaced
3843:97d9368ed485 3844:cf8b716d9ac2
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.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 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
24 from roundup import date, password, init, instance, configuration 24 from roundup import date, password, init, instance, configuration, support
25 25
26 from mocknull import MockNull 26 from mocknull import MockNull
27 27
28 config = configuration.CoreConfig() 28 config = configuration.CoreConfig()
29 config.DATABASE = "db" 29 config.DATABASE = "db"
876 self.db.indexer.force_reindex() 876 self.db.indexer.force_reindex()
877 self.db.post_init() 877 self.db.post_init()
878 self.db.indexer.quiet = 9 878 self.db.indexer.quiet = 9
879 self.assertEquals(self.db.indexer.search(['flebble'], self.db.issue), 879 self.assertEquals(self.db.indexer.search(['flebble'], self.db.issue),
880 {'1': {}}) 880 {'1': {}})
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
881 926
882 # 927 #
883 # searching tests follow 928 # searching tests follow
884 # 929 #
885 def testFindIncorrectProperty(self): 930 def testFindIncorrectProperty(self):

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