Skip to content

Commit

Permalink
Provide test for issue 41
Browse files Browse the repository at this point in the history
  • Loading branch information
msom committed Mar 11, 2015
1 parent 42ca8f5 commit 8186a6a
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions seantis/people/tests/test_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,45 @@ def test_default_indexes(self):

# person only
self.assertEqual(len(people_catalog(created=created)), 1)

def test_effectiveRange_index(self):
from Products.ZCatalog.ZCatalog import ZCatalog

# Create a patched search which queries only effective range
def patched_searchResults(self, REQUEST=None, used=None, **kw):
keys = [key for key in kw.keys() if key != 'effectiveRange']
for key in keys:
del kw[key]
return self._searchResults(REQUEST, used, **kw)

ZCatalog._searchResults = ZCatalog.searchResults
ZCatalog.searchResults = patched_searchResults

# Create test items
new_type = self.new_temporary_type(
behaviors=[IPerson.__identifier__],
klass='seantis.people.types.base.PersonBase'
)

set_columns(new_type.lookupSchema(), [['foo']])
on_type_modified(new_type)

with self.user('admin'):
created = datetime.now()

api.content.create(
id='007',
type=new_type.id,
container=self.new_temporary_folder(),
Subject='O O Seven',
title='James Bond',
description='Spy for his Majesty, the Queen',
created=created
)

# Query with both catalogs
portal_catalog = api.portal.get_tool('portal_catalog')
people_catalog = api.portal.get_tool('seantis_people_catalog')

self.assertIn('James Bond', [b.Title for b in portal_catalog()])
self.assertIn('James Bond', [b.Title for b in people_catalog()])

0 comments on commit 8186a6a

Please sign in to comment.