Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
davisagli committed Sep 20, 2023
1 parent c88657c commit 9fdc38c
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions plone/app/querystring/tests/testRegistryReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
@implementer(IVocabularyFactory)
class TestVocabulary:
def __call__(self, context):
return SimpleVocabulary([SimpleVocabulary.createTerm("foo", "foo", "bar")])
term = "subsite term" if getattr(context, "id", None) == "subsite" else "term"
return SimpleVocabulary([SimpleVocabulary.createTerm(term, term, term)])


class TestRegistryReader(unittest.TestCase):
Expand Down Expand Up @@ -82,7 +83,21 @@ def test_get_vocabularies(self):
result = reader.parseRegistry()
result = reader.getVocabularyValues(result)
vocabulary_result = result.get("plone.app.querystring.field.reviewState.values")
self.assertEqual(vocabulary_result, {"foo": {"title": "bar"}})
self.assertEqual(vocabulary_result, {"term": {"title": "term"}})

def test_get_vocabularies_in_context(self):
portal = self.layer["portal"]
subsite = portal[portal.invokeFactory(
"Document", "subsite", title="Subsite"
)]

registry = self.createRegistry(td.test_vocabulary_xml)
reader = IQuerystringRegistryReader(registry)
reader.vocab_context = subsite
result = reader.parseRegistry()
result = reader.getVocabularyValues(result)
vocabulary_result = result.get("plone.app.querystring.field.reviewState.values")
self.assertEqual(vocabulary_result, {"subsite term": {"title": "subsite term"}})

def test_map_operations_clean(self):
"""tests if mapOperations is getting all operators correctly"""
Expand Down

0 comments on commit 9fdc38c

Please sign in to comment.