[Checkins] SVN: Products.ZCatalog/trunk/ Provide some `integration` tests for not-support and document behavior regarding indexes with no entries for some documents
Hano Schlichting
cvs-admin at zope.org
Sun Mar 25 20:38:04 UTC 2012
Log message for revision 124727:
Provide some `integration` tests for not-support and document behavior regarding indexes with no entries for some documents
Changed:
U Products.ZCatalog/trunk/CHANGES.txt
U Products.ZCatalog/trunk/src/Products/ZCatalog/tests/test_catalog.py
U Products.ZCatalog/trunk/src/Products/ZCatalog/tests/test_zcatalog.py
-=-
Modified: Products.ZCatalog/trunk/CHANGES.txt
===================================================================
--- Products.ZCatalog/trunk/CHANGES.txt 2012-03-25 14:42:57 UTC (rev 124726)
+++ Products.ZCatalog/trunk/CHANGES.txt 2012-03-25 20:38:00 UTC (rev 124727)
@@ -9,7 +9,12 @@
purely exclusive queries. For example:
`{'foo': {'query': ['a', 'ab'], 'not': 'a'}}`,
`{'foo': {'query': 'a', 'range': 'min', 'not': ['a', 'e', 'f']}}` and
- `{'foo': {'not': ['a', 'b']}}`.
+ `{'foo': {'not': ['a', 'b']}}`. Note that negative filtering on an index
+ still restricts items to those having a value in the index. So with 10
+ documents, 5 of them in the `foo` index with a value of `1`, a query for
+ `not 1` will return no items instead of the 5 items without a value. You
+ need to index a dummy/default value if you want to consider all items for
+ a particular index.
- Updated deprecation warnings to point to Zope 4 instead of 2.14.
Modified: Products.ZCatalog/trunk/src/Products/ZCatalog/tests/test_catalog.py
===================================================================
--- Products.ZCatalog/trunk/src/Products/ZCatalog/tests/test_catalog.py 2012-03-25 14:42:57 UTC (rev 124726)
+++ Products.ZCatalog/trunk/src/Products/ZCatalog/tests/test_catalog.py 2012-03-25 20:38:00 UTC (rev 124727)
@@ -53,6 +53,8 @@
def __init__(self, num):
self.num = num
+ if isinstance(num, int) and (self.num % 10) == 0:
+ self.ends_in_zero = True
def col1(self):
return 'col1'
@@ -180,11 +182,13 @@
index_factory=OkapiIndex, lexicon_id='lexicon')
att3 = KeywordIndex('att3')
num = FieldIndex('num')
+ ends_in_zero = FieldIndex('ends_in_zero')
self._catalog.addIndex('att1', att1)
self._catalog.addIndex('att2', att2)
self._catalog.addIndex('att3', att3)
self._catalog.addIndex('num', num)
+ self._catalog.addIndex('ends_in_zero', ends_in_zero)
self._catalog.addColumn('att1')
self._catalog.addColumn('att2')
self._catalog.addColumn('att3')
@@ -419,6 +423,21 @@
# _getSortIndex
# searchResults
+ def test_search_not(self):
+ query = dict(att1='att1', num={'not': [0, 1]})
+ result = self._catalog(query)
+ self.assertEqual(len(result), self.upper - 2)
+
+ def test_search_not_nothing(self):
+ query = dict(att1='att1', col1={'not': 'col1'})
+ result = self._catalog(query)
+ self.assertEqual(len(result), 0)
+
+ def test_search_not_no_value_in_index(self):
+ query = dict(att1='att1', ends_in_zero={'not': False})
+ result = self._catalog(query)
+ self.assertEqual(len(result), 10)
+
def testResultLength(self):
a = self._catalog(att1='att1')
self.assertEqual(len(a), self.upper,
Modified: Products.ZCatalog/trunk/src/Products/ZCatalog/tests/test_zcatalog.py
===================================================================
--- Products.ZCatalog/trunk/src/Products/ZCatalog/tests/test_zcatalog.py 2012-03-25 14:42:57 UTC (rev 124726)
+++ Products.ZCatalog/trunk/src/Products/ZCatalog/tests/test_zcatalog.py 2012-03-25 20:38:00 UTC (rev 124727)
@@ -282,6 +282,11 @@
sr = self._catalog.search(query)
self.assertEqual(len(sr), 3)
+ def testSearchNot(self):
+ query = {'title': {'not': ['0']}}
+ sr = self._catalog.search(query)
+ self.assertEqual(len(sr), 9)
+
# resolve_url
# resolve_path
# manage_normalize_paths
More information about the checkins
mailing list