def setUp(self): self._vocabulary = Vocabulary.Vocabulary('Vocabulary', 'Vocabulary', globbing=1) col1 = FieldIndex('col1') col2 = TextIndex('col2') col3 = KeywordIndex('col3') self._catalog = Catalog() self._catalog.addIndex('col1', col1) self._catalog.addIndex('col2', col2) self._catalog.addIndex('col3', col3) self._catalog.addColumn('col1') self._catalog.addColumn('col2') self._catalog.addColumn('col3') att1 = FieldIndex('att1') att2 = TextIndex('att2') att3 = KeywordIndex('att3') num = FieldIndex('num') self._catalog.addIndex('att1', att1) self._catalog.addIndex('att2', att2) self._catalog.addIndex('att3', att3) self._catalog.addIndex('num', num) self._catalog.addColumn('att1') self._catalog.addColumn('att2') self._catalog.addColumn('att3') self._catalog.addColumn('num') for x in range(0, self.upper): self._catalog.catalogObject(dummy(self.nums[x]), ` x `) self._catalog.aq_parent = dummy('foo') # fake out acquisition
def _make_one(self, extra=None): from Products.ZCatalog.Catalog import Catalog catalog = Catalog() catalog.lexicon = PLexicon('lexicon') att1 = FieldIndex('att1') att2 = ZCTextIndex('att2', caller=catalog, index_factory=OkapiIndex, lexicon_id='lexicon') catalog.addIndex('att2', att2) num = FieldIndex('num') catalog.addIndex('att1', att1) catalog.addIndex('num', num) catalog.addColumn('num') foo = MultiFieldIndex('foo') catalog.addIndex('foo', foo) if extra is not None: extra(catalog) for x in range(0, self.upper): catalog.catalogObject(Dummy(self.nums[x]), repr(x)) return catalog.__of__(Dummy('foo'))
def __init__(self, id, title='', vocab_id=None, container=None): # ZCatalog no longer cares about vocabularies # so the vocab_id argument is ignored (Casey) if container is not None: self = self.__of__(container) self.id = id self.title = title self.threshold = 10000 self.long_query_time = 0.1 # in seconds self._v_total = 0 self._catalog = Catalog()
def setUp(self): self._vocabulary = Vocabulary.Vocabulary('Vocabulary', 'Vocabulary', globbing=1) self._catalog = Catalog() index = FieldIndex('number') self._catalog.addIndex('number', index) self._catalog.addColumn('number') for i in range(5000): obj = objRS(random.randrange(0, 20000)) self._catalog.catalogObject(obj, i) self._catalog.aq_parent = objRS(200)
def _make_one(self): from Products.ZCatalog.Catalog import Catalog catalog = Catalog() catalog.lexicon = PLexicon('lexicon') att1 = FieldIndex('att1') att2 = ZCTextIndex('att2', caller=catalog, index_factory=OkapiIndex, lexicon_id='lexicon') att3 = KeywordIndex('att3') catalog.addIndex('att1', att1) catalog.addIndex('att2', att2) catalog.addIndex('att3', att3) for x in range(0, self.upper): catalog.catalogObject(Dummy(x), repr(x)) return catalog.__of__(Dummy('foo'))
def _make_one(self): from Products.ZCatalog.Catalog import Catalog catalog = Catalog() catalog.lexicon = PLexicon('lexicon') idx = ZCTextIndex('title', caller=catalog, index_factory=OkapiIndex, lexicon_id='lexicon') catalog.addIndex('title', idx) catalog.addIndex('true', FieldIndex('true')) catalog.addColumn('title') for i in (1, 2, 3, 10, 11, 110, 111): obj = ZDummy(i) obj.true = True if i == 110: obj.true = False catalog.catalogObject(obj, str(i)) return catalog.__of__(ZDummy(1))
def setUp(self): vocabulary = Vocabulary.Vocabulary('Vocabulary', 'Vocabulary', globbing=1) self.catalogs = [] for i in range(3): cat = Catalog() cat.addIndex('num', FieldIndex('num')) cat.addIndex('big', FieldIndex('big')) cat.addIndex('title', TextIndex('title')) cat.vocabulary = vocabulary cat.aq_parent = zdummy(16336) for i in range(10): obj = zdummy(i) obj.big = i > 5 cat.catalogObject(obj, str(i)) self.catalogs.append(cat)
def _makeOne(self): from Products.ZCatalog.Catalog import Catalog return Catalog()
def setUp(self): cleanup.CleanUp.setUp(self) from Products.ZCatalog.Catalog import Catalog self.cat = Catalog('catalog')
def setUp(self): self._vocabulary = Vocabulary.Vocabulary('Vocabulary', 'Vocabulary', globbing=1) self._catalog = Catalog()
def setUp(self): cleanup.CleanUp.setUp(self) self.cat = Catalog('catalog')
def test_index(self): """Test the index in icalendar/rfc5545 recurrence mode. """ # Initialize the catalog with DateRecurringIndex from Products.DateRecurringIndex.index import DateRecurringIndex dri = DateRecurringIndex('start', extra=DummyExtras(recurrence_type='ical', recurdef='recurdef', until='until')) # Index must have be the same name as dri's id from Products.ZCatalog.Catalog import Catalog cat = Catalog() cat.addIndex('start', dri) cat.addColumn('id') # catalog needs to be contained somewhere, otherwise # aquisition-wrapping of result brains doesn't work from OFS.Folder import Folder portal = Folder(id='portal') cat.__parent__ = portal # Let's define some dummy events and catalog them. from datetime import datetime import pytz cet = pytz.timezone('CET') # Index the same event more than once and test if index size changes. test_event = DummyEvent(id='test_event', start=datetime(2001, 1, 1), recurdef='RRULE:FREQ=DAILY;INTERVAL=1;COUNT=5') self.assertEqual(cat.catalogObject(test_event, 'test_event'), 1) self.assertEqual(dri.indexSize(), 5) test_event = DummyEvent(id='test_event', start=datetime(2001, 1, 1), recurdef='RRULE:FREQ=DAILY;INTERVAL=1;COUNT=3') self.assertEqual(cat.catalogObject(test_event, 'test_event'), 1) self.assertEqual(dri.indexSize(), 3) test_event = DummyEvent(id='test_event', start=datetime(2001, 1, 1), recurdef='RRULE:FREQ=DAILY;INTERVAL=1;COUNT=8') self.assertEqual(cat.catalogObject(test_event, 'test_event'), 1) self.assertEqual(dri.indexSize(), 8) cat.uncatalogObject('test_event') self.assertEqual(dri.indexSize(), 0) # Index for querying later on... nonr = DummyEvent(id='nonr', start=datetime(2010, 10, 10, 0, 0, tzinfo=cet)) days = DummyEvent(id='days', start=datetime(2010, 10, 10, 0, 0, tzinfo=cet), recurdef='RRULE:FREQ=DAILY;INTERVAL=10;COUNT=5') mins = DummyEvent(id='mins', start=datetime(2010, 10, 10, 0, 0, tzinfo=cet), recurdef='RRULE:FREQ=MINUTELY;INTERVAL=10;COUNT=5') dstc = DummyEvent(id='dstc', start=datetime(2010, 10, 20, 0, 0, tzinfo=cet), recurdef='RRULE:FREQ=HOURLY;INTERVAL=1;COUNT=7') cat.catalogObject(nonr, 'nonr') cat.catalogObject(days, 'days') cat.catalogObject(mins, 'mins') cat.catalogObject(dstc, 'dstc') # Query min one specific date query = { 'start': { 'query': datetime(2010, 10, 10, 0, 0, tzinfo=cet), 'range': 'min', }, } res = cat(**query) self.assertEqual(sorted([it.id for it in res]), ['days', 'dstc', 'mins', 'nonr']) # Query max one specific date query = { 'start': { 'query': datetime(2010, 10, 10, 0, 0, tzinfo=cet), 'range': 'max', }, } res = cat(**query) self.assertEqual(sorted([it.id for it in res]), ['days', 'mins', 'nonr']) # Query timerange over days and dstc set query = { 'start': { 'query': [ datetime(2010, 10, 11, 0, 0, tzinfo=cet), datetime(2010, 11, 20, 0, 0, tzinfo=cet) ], 'range': 'min:max', }, } res = cat(**query) self.assertEqual(sorted([brain.id for brain in res]), ['days', 'dstc']) # Query timerange over mins set query = { 'start': { 'query': [ datetime(2010, 10, 10, 0, 10, tzinfo=cet), datetime(2010, 10, 10, 0, 40, tzinfo=cet) ], 'range': 'min:max', }, } res = cat(**query) self.assertEqual(sorted([brain.id for brain in res]), ['mins'])