From af83a860ead1f61b667341c49c5905c304864a71 Mon Sep 17 00:00:00 2001 From: jackahl Date: Thu, 5 May 2022 11:05:14 +0200 Subject: [PATCH 1/4] allow including tokens in querystring vocabs --- news/1402.bugfix | 1 + .../restapi/tests/test_services_querystring.py | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 news/1402.bugfix diff --git a/news/1402.bugfix b/news/1402.bugfix new file mode 100644 index 0000000000..09cfe7e40b --- /dev/null +++ b/news/1402.bugfix @@ -0,0 +1 @@ +make `test_endpoint_inlines_vocabularies` more resilient and able to pass with vocabularies that include tokens diff --git a/src/plone/restapi/tests/test_services_querystring.py b/src/plone/restapi/tests/test_services_querystring.py index 1203ab6336..ad9b9711c1 100644 --- a/src/plone/restapi/tests/test_services_querystring.py +++ b/src/plone/restapi/tests/test_services_querystring.py @@ -99,10 +99,26 @@ def test_endpoint_inlines_vocabularies(self): "published": {"title": "Published with accent \xe9 [published]"}, "visible": {"title": "Public draft [visible]"}, } + + self.assertTrue("external" in (idx["values"].keys())) self.assertTrue( - all(elem in idx["values"].items() for elem in expected_vocab_values.items()) + 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") From f9d56045e70a65fc5e4b069c45505cf0dec0e7be Mon Sep 17 00:00:00 2001 From: jackahl Date: Thu, 5 May 2022 11:14:47 +0200 Subject: [PATCH 2/4] update changelog --- news/1402.bugfix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/news/1402.bugfix b/news/1402.bugfix index 09cfe7e40b..56990ce923 100644 --- a/news/1402.bugfix +++ b/news/1402.bugfix @@ -1 +1 @@ -make `test_endpoint_inlines_vocabularies` more resilient and able to pass with vocabularies that include tokens +make `test_endpoint_inlines_vocabularies` more resilient and able to pass with vocabularies that include tokens [jackahl] From 9fb0ee7b4a205e12cbc36e4b5c4aca0a6a496956 Mon Sep 17 00:00:00 2001 From: jackahl Date: Sun, 22 May 2022 11:17:18 +0200 Subject: [PATCH 3/4] add tokens to querystring service response test mock data --- .../restapi/tests/test_services_querystring.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/plone/restapi/tests/test_services_querystring.py b/src/plone/restapi/tests/test_services_querystring.py index ad9b9711c1..65e667944f 100644 --- a/src/plone/restapi/tests/test_services_querystring.py +++ b/src/plone/restapi/tests/test_services_querystring.py @@ -89,15 +89,19 @@ 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"}, } self.assertTrue("external" in (idx["values"].keys())) From 88fed9c1b8c584afa318bc4a025a28d64816e929 Mon Sep 17 00:00:00 2001 From: jackahl Date: Sun, 22 May 2022 11:24:11 +0200 Subject: [PATCH 4/4] removed redundand text criteria --- src/plone/restapi/tests/test_services_querystring.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/plone/restapi/tests/test_services_querystring.py b/src/plone/restapi/tests/test_services_querystring.py index 65e667944f..7d4277ea42 100644 --- a/src/plone/restapi/tests/test_services_querystring.py +++ b/src/plone/restapi/tests/test_services_querystring.py @@ -104,7 +104,6 @@ def test_endpoint_inlines_vocabularies(self): "visible": {"title": "Public draft [visible]", "token": "visible"}, } - self.assertTrue("external" in (idx["values"].keys())) self.assertTrue( set(expected_vocab_values.keys()).issubset((idx["values"].keys())) )