Skip to content

Commit 0f1da2c

Browse files
authored
Merge pull request #181 from plone/Products.ZCatalog
Fix tests for `not` queries in Products.ZCatalog 7.2.0+
2 parents d0deaaa + e82d5a9 commit 0f1da2c

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

news/+130d79d1.tests.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix tests for ``not`` queries in ``Products.ZCatalog`` 7.2.0+. [maurits]

src/plone/app/querystring/tests/testQueryBuilder.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,14 @@ def testMakeQueryWithSubjectNot(self):
123123
}
124124
]
125125
results = self.querybuilder._makequery(query=query)
126-
self.assertEqual(len(results), 1)
127-
self.assertEqual(results[0].getURL(), "http://nohost/plone/testfolder")
126+
# Since Products.ZCatalog 7.2.0 the Plone Site is also returned.
127+
# To keep the test compatible with both older and newer versions,
128+
# only assert that the page with subject 'Lorem' is not part of the
129+
# results (the presence of the Plone site itself may vary by ZCatalog
130+
# version).
131+
self.assertNotIn(
132+
self.testpage.absolute_url(), [brain.getURL() for brain in results]
133+
)
128134

129135
def testMakeQueryWithMultipleSubject(self):
130136
self.testpage.setSubject(["Lorem"])
@@ -153,8 +159,14 @@ def testMakeQueryWithMultipleSubjectNot(self):
153159
}
154160
]
155161
results = self.querybuilder._makequery(query=query)
156-
self.assertEqual(len(results), 1)
157-
self.assertEqual(results[0].getURL(), "http://nohost/plone/testfolder")
162+
# Since Products.ZCatalog 7.2.0 the Plone Site is also returned.
163+
# To keep the test compatible with both older and newer versions,
164+
# only assert that the page with subject 'Lorem' is not part of the
165+
# results (the presence of the Plone site itself may vary by ZCatalog
166+
# version).
167+
self.assertNotIn(
168+
self.testpage.absolute_url(), [brain.getURL() for brain in results]
169+
)
158170

159171
def testMakeQueryWithSubjectWithSpecialCharacters(self):
160172
self.testpage.setSubject(["Äüö"])

0 commit comments

Comments
 (0)