comparison test/db_test_base.py @ 3935:1dab48842cbd

Throwing up hands in resignation and finally deleting the metakit backend. It's just too out-of-sync with the rest of Roundup's backends and has fundamental compatibility issues. Also, I've never really understood the code.
author Richard Jones <richard@users.sourceforge.net>
date Fri, 26 Oct 2007 06:52:26 +0000
parents 65b5fffac46b
children c68581212cf7
comparison
equal deleted inserted replaced
3934:8c75e8fce5dc 3935:1dab48842cbd
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.91 2007-10-25 05:24:50 richard Exp $ 18 # $Id: db_test_base.py,v 1.92 2007-10-26 06:52:26 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
929 self.db.indexer.quiet = 9 929 self.db.indexer.quiet = 9
930 self.assertEquals(self.db.indexer.search(['flebble'], self.db.issue), 930 self.assertEquals(self.db.indexer.search(['flebble'], self.db.issue),
931 {'1': {}}) 931 {'1': {}})
932 932
933 def testIndexingOnImport(self): 933 def testIndexingOnImport(self):
934 # import a message
934 msgcontent = 'Glrk' 935 msgcontent = 'Glrk'
935 msgid = self.db.msg.import_list(['content', 'files', 'recipients'], 936 msgid = self.db.msg.import_list(['content', 'files', 'recipients'],
936 [repr(msgcontent), '[]', '[]']) 937 [repr(msgcontent), '[]', '[]'])
937 msg_filename = self.db.filename(self.db.msg.classname, msgid, 938 msg_filename = self.db.filename(self.db.msg.classname, msgid,
938 create=1) 939 create=1)
939 support.ensureParentsExist(msg_filename) 940 support.ensureParentsExist(msg_filename)
940 msg_file = open(msg_filename, 'w') 941 msg_file = open(msg_filename, 'w')
941 msg_file.write(msgcontent) 942 msg_file.write(msgcontent)
942 msg_file.close() 943 msg_file.close()
943 944
944 945 # import a file
945 filecontent = 'Brrk' 946 filecontent = 'Brrk'
946 fileid = self.db.file.import_list(['content'], [repr(filecontent)]) 947 fileid = self.db.file.import_list(['content'], [repr(filecontent)])
947 file_filename = self.db.filename(self.db.file.classname, fileid, 948 file_filename = self.db.filename(self.db.file.classname, fileid,
948 create=1) 949 create=1)
949 support.ensureParentsExist(file_filename) 950 support.ensureParentsExist(file_filename)
950 file_file = open(file_filename, 'w') 951 file_file = open(file_filename, 'w')
951 file_file.write(filecontent) 952 file_file.write(filecontent)
952 file_file.close() 953 file_file.close()
953 954
955 # import an issue
954 title = 'Bzzt' 956 title = 'Bzzt'
955 nodeid = self.db.issue.import_list(['title', 'messages', 'files', 957 nodeid = self.db.issue.import_list(['title', 'messages', 'files',
956 'spam', 958 'spam', 'nosy', 'superseder'], [repr(title), repr([msgid]),
957 'nosy', 959 repr([fileid]), '[]', '[]', '[]'])
958 'superseder'],
959 [repr(title),
960 repr([msgid]),
961 repr([fileid]),
962 repr([]),
963 repr([]),
964 repr([])])
965 self.db.commit() 960 self.db.commit()
966 961
967 # Content of title attribute is indexed 962 # Content of title attribute is indexed
968 self.assertEquals(self.db.indexer.search([title], self.db.issue), 963 self.assertEquals(self.db.indexer.search([title], self.db.issue),
969 {str(nodeid):{}}) 964 {str(nodeid):{}})
970 # Content of message is indexed 965 # Content of message is indexed
971 self.assertEquals(self.db.indexer.search([msgcontent], self.db.issue), 966 self.assertEquals(self.db.indexer.search([msgcontent], self.db.issue),
972 {str(nodeid):{'messages':[str(msgid)]}}) 967 {str(nodeid):{'messages':[str(msgid)]}})
973 # Content of file is indexed 968 # Content of file is indexed
974 self.assertEquals(self.db.indexer.search([filecontent], self.db.issue), 969 self.assertEquals(self.db.indexer.search([filecontent], self.db.issue),
975 {str(nodeid):{'files':[str(fileid)]}}) 970 {str(nodeid):{'files':[str(fileid)]}})
976 971
977 972
978 973
979 # 974 #
980 # searching tests follow 975 # searching tests follow
1885 # modify "a" schema 1880 # modify "a" schema
1886 self.init_amod() 1881 self.init_amod()
1887 self.assertEqual(self.db.a.get(aid, 'name'), 'apple') 1882 self.assertEqual(self.db.a.get(aid, 'name'), 'apple')
1888 self.assertEqual(self.db.a.get(aid, 'newstr'), None) 1883 self.assertEqual(self.db.a.get(aid, 'newstr'), None)
1889 self.assertEqual(self.db.a.get(aid, 'newint'), None) 1884 self.assertEqual(self.db.a.get(aid, 'newint'), None)
1890 self.assertEqual(self.db.a.get(aid, 'newnum'), None) 1885 # hack - metakit can't return None for missing values, and we're not
1891 self.assertEqual(self.db.a.get(aid, 'newbool'), None) 1886 # really checking for that behavior here anyway
1887 self.assert_(not self.db.a.get(aid, 'newnum'))
1888 self.assert_(not self.db.a.get(aid, 'newbool'))
1892 self.assertEqual(self.db.a.get(aid, 'newdate'), None) 1889 self.assertEqual(self.db.a.get(aid, 'newdate'), None)
1893 self.assertEqual(self.db.b.get(aid, 'name'), 'bear') 1890 self.assertEqual(self.db.b.get(aid, 'name'), 'bear')
1894 aid2 = self.db.a.create(name='aardvark', newstr='booz') 1891 aid2 = self.db.a.create(name='aardvark', newstr='booz')
1895 self.db.commit(); self.db.close() 1892 self.db.commit(); self.db.close()
1896 1893

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