Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/1402.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
make `test_endpoint_inlines_vocabularies` more resilient and able to pass with vocabularies that include tokens
18 changes: 17 additions & 1 deletion src/plone/restapi/tests/test_services_querystring.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,26 @@ def test_endpoint_inlines_vocabularies(self):
"published": {"title": "Published with accent \xe9 [published]"},
"visible": {"title": "Public draft [visible]"},
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With your refactoring of the tests, the 'expected_vocab_values' can already be updated with the additional token.

self.assertTrue("external" in (idx["values"].keys()))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

included in the subsequent test

self.assertTrue(
all(elem in idx["values"].items() for elem in expected_vocab_values.items())

@jackahl jackahl May 5, 2022

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ksuess I removed this check as it only was breaking with the new inclusion of tokens inside of vocabularies returned in plone/plone.app.querystring#107.

Also I was not able to determine what is tested here anyways in a glimbs, as this nesting of loops, although short and elegant, is not really easy to read.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am OK with your refactoring, especially because this test 'test_endpoint_inlines_vocabularies' is not about testing the existence of review states, but about testing the format of the response of the 'querystring' endpoint.

set(expected_vocab_values.keys()).issubset((idx["values"].keys()))
)

self.assertEqual(
expected_vocab_values["external"]["title"],
idx["values"]["external"]["title"],
)

# Only checking token if it actually exists
if len(idx["values"]["external"]) > 1:
self.assertTrue("token" in (idx["values"]["external"].keys()))

self.assertEqual(
"external",
idx["values"]["external"]["token"],
)

def test_endpoint_inlines_operators(self):
response = self.api_session.get("/@querystring")

Expand Down