comparison test/db_test_base.py @ 3601:7b25567f0f54

indexing may be turned off for FileClass "content" now
author Richard Jones <richard@users.sourceforge.net>
date Thu, 27 Apr 2006 01:39:47 +0000
parents f47bddab5a49
children 57c66056ffe4
comparison
equal deleted inserted replaced
3600:1113e1456093 3601:7b25567f0f54
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.68 2006-03-03 02:02:50 richard Exp $ 18 # $Id: db_test_base.py,v 1.69 2006-04-27 01:39:47 richard 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
71 user = module.Class(db, "user", username=String(), password=Password(), 71 user = module.Class(db, "user", username=String(), password=Password(),
72 assignable=Boolean(), age=Number(), roles=String()) 72 assignable=Boolean(), age=Number(), roles=String())
73 user.setkey("username") 73 user.setkey("username")
74 file = module.FileClass(db, "file", name=String(), type=String(), 74 file = module.FileClass(db, "file", name=String(), type=String(),
75 comment=String(indexme="yes"), fooz=Password()) 75 comment=String(indexme="yes"), fooz=Password())
76 file_nidx = module.FileClass(db, "file_nidx", content=String(indexme='no'))
76 issue = module.IssueClass(db, "issue", title=String(indexme="yes"), 77 issue = module.IssueClass(db, "issue", title=String(indexme="yes"),
77 status=Link("status"), nosy=Multilink("user"), deadline=Date(), 78 status=Link("status"), nosy=Multilink("user"), deadline=Date(),
78 foo=Interval(), files=Multilink("file"), assignedto=Link('user'), 79 foo=Interval(), files=Multilink("file"), assignedto=Link('user'),
79 priority=Link('priority')) 80 priority=Link('priority'))
80 stuff = module.Class(db, "stuff", stuff=String()) 81 stuff = module.Class(db, "stuff", stuff=String())
782 d[i1]['files'].sort() 783 d[i1]['files'].sort()
783 self.assertEquals(d, {i1: {'files': [f1, f2]}}) 784 self.assertEquals(d, {i1: {'files': [f1, f2]}})
784 self.assertEquals(self.db.indexer.search(['hello'], self.db.issue), 785 self.assertEquals(self.db.indexer.search(['hello'], self.db.issue),
785 {i1: {'files': [f2]}}) 786 {i1: {'files': [f2]}})
786 787
788 def testFileClassIndexingNoNoNo(self):
789 f1 = self.db.file.create(content='hello')
790 self.db.commit()
791 self.assertEquals(self.db.indexer.search(['hello'], self.db.file),
792 {'1': {}})
793
794 f1 = self.db.file_nidx.create(content='hello')
795 self.db.commit()
796 self.assertEquals(self.db.indexer.search(['hello'], self.db.file_nidx),
797 {})
798
787 def testForcedReindexing(self): 799 def testForcedReindexing(self):
788 self.db.issue.create(title="flebble frooz") 800 self.db.issue.create(title="flebble frooz")
789 self.db.commit() 801 self.db.commit()
790 self.assertEquals(self.db.indexer.search(['flebble'], self.db.issue), 802 self.assertEquals(self.db.indexer.search(['flebble'], self.db.issue),
791 {'1': {}}) 803 {'1': {}})
1256 self.db = self.module.Database(config, 'admin') 1268 self.db = self.module.Database(config, 'admin')
1257 a = self.module.Class(self.db, "a", name=String()) 1269 a = self.module.Class(self.db, "a", name=String())
1258 a.setkey("name") 1270 a.setkey("name")
1259 self.db.post_init() 1271 self.db.post_init()
1260 1272
1273 def test_fileClassProps(self):
1274 self.db = self.module.Database(config, 'admin')
1275 a = self.module.FileClass(self.db, 'a')
1276 l = a.getprops().keys()
1277 l.sort()
1278 self.assert_(l, ['activity', 'actor', 'content', 'created',
1279 'creation', 'type'])
1280
1261 def init_ab(self): 1281 def init_ab(self):
1262 self.db = self.module.Database(config, 'admin') 1282 self.db = self.module.Database(config, 'admin')
1263 a = self.module.Class(self.db, "a", name=String()) 1283 a = self.module.Class(self.db, "a", name=String())
1264 a.setkey("name") 1284 a.setkey("name")
1265 b = self.module.Class(self.db, "b", name=String(), 1285 b = self.module.Class(self.db, "b", name=String(),

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