Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow including tokens in querystring vocabs #1403

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
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 [jackahl]
35 changes: 27 additions & 8 deletions src/plone/restapi/tests/test_services_querystring.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,20 +89,39 @@ def test_endpoint_inlines_vocabularies(self):
)

expected_vocab_values = {
"external": {"title": "Externally visible [external]"},
"internal": {"title": "Internal draft [internal]"},
"external": {"title": "Externally visible [external]", "token": "external"},
"internal": {"title": "Internal draft [internal]", "token": "internal"},
"internally_published": {
"title": "Internally published [internally_published]"
"title": "Internally published [internally_published]",
"token": "internally_published",
},
"pending": {"title": "Pending [pending]"},
"private": {"title": "Private [private]"},
"published": {"title": "Published with accent \xe9 [published]"},
"visible": {"title": "Public draft [visible]"},
"pending": {"title": "Pending [pending]", "token": "pending"},
"private": {"title": "Private [private]", "token": "private"},
"published": {
"title": "Published with accent \xe9 [published]",
"token": "published",
},
"visible": {"title": "Public draft [visible]", "token": "visible"},
}

Copy link
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(
all(elem in idx["values"].items() for elem in expected_vocab_values.items())
Copy link
Sponsor Member Author

@jackahl jackahl May 5, 2022

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
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