Skip to content

Commit

Permalink
demonstrate problem in issue #148
Browse files Browse the repository at this point in the history
  • Loading branch information
jensens committed Jan 13, 2025
1 parent bc3fb48 commit c5377fb
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/Products/ZCatalog/tests/test_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,35 @@ def test_keyword_index_length(self):
a = catalog(att3='none')
self.assertEqual(len(a), 0)

def test_keyword_index_index_not_query_order(self):
# Queries with empty keys used to return all.
from Products.ZCatalog.Catalog import Catalog
catalog = Catalog()
catalog.addIndex('keywords', KeywordIndex('keywords'))
catalog.addIndex('field', FieldIndex('field'))

class DummyKWNot(ExtensionClass.Base):
field = 'foo'
def __init__(self, keywords=None):
if keywords:
self.keywords = keywords


catalog.catalogObject(DummyKWNot([10, 11, 12]), "1")
catalog.catalogObject(DummyKWNot([11, 12]), "2")
catalog.catalogObject(DummyKWNot(), "3")

from Products.ZCatalog.plan import CatalogPlan
from unittest.mock import patch

with patch.object(CatalogPlan, "plan", return_value=["field", "keywords"]):
a = catalog({'keywords': {"not": [10]}, 'field': 'foo'})
self.assertEqual(len(a), 2)

with patch.object(CatalogPlan, "plan", return_value=["keywords", "field"]):
a = catalog({'keywords': {"not": [10]}, 'field': 'foo'})
self.assertEqual(len(a), 2)


class TestCatalogSortBatch(unittest.TestCase):

Expand Down

0 comments on commit c5377fb

Please sign in to comment.