-
-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Branch: refs/heads/main Date: 2023-10-09T23:39:41+02:00 Author: Gil Forcada Codinachs (gforcada) <[email protected]> Commit: plone/plone.restapi@063e4e0 Fix regex asserts (#1719) * fix(py3.12): deprecated methods I used the approach suggested on https://stackoverflow.com/questions/20050913 This makes plone.restapi tests pass on Python 3.12. * Add news entry * Apply suggestions from code review --------- Co-authored-by: David Glick <[email protected]> Files changed: A news/1.bugfix M src/plone/restapi/tests/test_batching.py M src/plone/restapi/tests/test_permissions.py M src/plone/restapi/tests/test_search.py M src/plone/restapi/tests/test_serializer_catalog.py M src/plone/restapi/tests/test_services.py M src/plone/restapi/tests/test_services_querystring.py
- Loading branch information
Showing
1 changed file
with
32 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,35 @@ | ||
Repository: plone.app.viewletmanager | ||
|
||
|
||
Branch: refs/heads/master | ||
Date: 2023-10-08T13:26:54+02:00 | ||
Author: Johannes Raggam (thet) <[email protected]> | ||
Commit: https://github.com/plone/plone.app.viewletmanager/commit/474b364e561cc1d39fa3ce3ae8cb713f3dedd088 | ||
|
||
Fix docs on how to insert a viewlet before/after. Not even worth a changelog entry. | ||
Repository: plone.restapi | ||
|
||
|
||
Branch: refs/heads/main | ||
Date: 2023-10-09T23:39:41+02:00 | ||
Author: Gil Forcada Codinachs (gforcada) <[email protected]> | ||
Commit: https://github.com/plone/plone.restapi/commit/063e4e084ba8e4e75bb82c727ed36e24966bb532 | ||
|
||
Fix regex asserts (#1719) | ||
|
||
* fix(py3.12): deprecated methods | ||
|
||
I used the approach suggested on https://stackoverflow.com/questions/20050913 | ||
|
||
This makes plone.restapi tests pass on Python 3.12. | ||
|
||
* Add news entry | ||
|
||
* Apply suggestions from code review | ||
|
||
--------- | ||
|
||
Co-authored-by: David Glick <[email protected]> | ||
|
||
Files changed: | ||
M plone/app/viewletmanager/exportimport/storage.py | ||
|
||
b'diff --git a/plone/app/viewletmanager/exportimport/storage.py b/plone/app/viewletmanager/exportimport/storage.py\nindex 2afbbd3..a094a21 100644\n--- a/plone/app/viewletmanager/exportimport/storage.py\n+++ b/plone/app/viewletmanager/exportimport/storage.py\n@@ -14,8 +14,8 @@\n \n <order manager="plone.portalheader" skinname="My\n Custom Theme" based-on="Plone Default">\n- <viewlet name="plone.global_sections" insertbefore="*"/>\n- <viewlet name="plone.site_actions" insertafter="plone.searchbox"/>\n+ <viewlet name="plone.global_sections" insert-before="*"/>\n+ <viewlet name="plone.site_actions" insert-after="plone.searchbox"/>\n </order>\n \n Hide a viewlet (here we hide the colophon for \'My Custom Theme\')::\n' | ||
|
||
Repository: plone.app.viewletmanager | ||
|
||
|
||
Branch: refs/heads/master | ||
Date: 2023-10-08T15:13:48+02:00 | ||
Author: Peter Mathis (petschki) <[email protected]> | ||
Commit: https://github.com/plone/plone.app.viewletmanager/commit/52a8c8355b72862eb759f74a1f43b3d1f18f4e8a | ||
|
||
Merge pull request #42 from plone/minordocfix | ||
|
||
Files changed: | ||
M plone/app/viewletmanager/exportimport/storage.py | ||
|
||
b'diff --git a/plone/app/viewletmanager/exportimport/storage.py b/plone/app/viewletmanager/exportimport/storage.py\nindex 2afbbd3..a094a21 100644\n--- a/plone/app/viewletmanager/exportimport/storage.py\n+++ b/plone/app/viewletmanager/exportimport/storage.py\n@@ -14,8 +14,8 @@\n \n <order manager="plone.portalheader" skinname="My\n Custom Theme" based-on="Plone Default">\n- <viewlet name="plone.global_sections" insertbefore="*"/>\n- <viewlet name="plone.site_actions" insertafter="plone.searchbox"/>\n+ <viewlet name="plone.global_sections" insert-before="*"/>\n+ <viewlet name="plone.site_actions" insert-after="plone.searchbox"/>\n </order>\n \n Hide a viewlet (here we hide the colophon for \'My Custom Theme\')::\n' | ||
A news/1.bugfix | ||
M src/plone/restapi/tests/test_batching.py | ||
M src/plone/restapi/tests/test_permissions.py | ||
M src/plone/restapi/tests/test_search.py | ||
M src/plone/restapi/tests/test_serializer_catalog.py | ||
M src/plone/restapi/tests/test_services.py | ||
M src/plone/restapi/tests/test_services_querystring.py | ||
|
||
b'diff --git a/news/1.bugfix b/news/1.bugfix\nnew file mode 100644\nindex 000000000..1494e057f\n--- /dev/null\n+++ b/news/1.bugfix\n@@ -0,0 +1,2 @@\n+Replace deprecated assert methods.\n+[gforcada]\ndiff --git a/src/plone/restapi/tests/test_batching.py b/src/plone/restapi/tests/test_batching.py\nindex 810846298..3e809ebab 100644\n--- a/src/plone/restapi/tests/test_batching.py\n+++ b/src/plone/restapi/tests/test_batching.py\n@@ -455,7 +455,7 @@ def test_first_link_contained(self):\n \n self.request.form["b_size"] = 10\n batch = HypermediaBatch(self.request, items)\n- self.assertDictContainsSubset({"first": "http://nohost?b_start=0"}, batch.links)\n+ self.assertEqual(batch.links["first"], "http://nohost?b_start=0")\n \n def test_first_link_preserves_list_like_querystring_params(self):\n items = list(range(1, 26))\n@@ -478,14 +478,14 @@ def test_last_link_contained(self):\n \n self.request.form["b_size"] = 10\n batch = HypermediaBatch(self.request, items)\n- self.assertDictContainsSubset({"last": "http://nohost?b_start=20"}, batch.links)\n+ self.assertEqual(batch.links["last"], "http://nohost?b_start=20")\n \n def test_next_link_contained_if_necessary(self):\n items = list(range(1, 26))\n \n self.request.form["b_size"] = 10\n batch = HypermediaBatch(self.request, items)\n- self.assertDictContainsSubset({"next": "http://nohost?b_start=10"}, batch.links)\n+ self.assertEqual(batch.links["next"], "http://nohost?b_start=10")\n \n def test_next_link_omitted_on_last_page(self):\n items = list(range(1, 26))\n@@ -503,7 +503,7 @@ def test_prev_link_contained_if_necessary(self):\n self.request.form["b_size"] = 10\n self.request.form["b_start"] = 20\n batch = HypermediaBatch(self.request, items)\n- self.assertDictContainsSubset({"prev": "http://nohost?b_start=10"}, batch.links)\n+ self.assertEqual(batch.links["prev"], "http://nohost?b_start=10")\n \n def test_prev_link_omitted_on_first_page(self):\n items = list(range(1, 26))\ndiff --git a/src/plone/restapi/tests/test_permissions.py b/src/plone/restapi/tests/test_permissions.py\nindex 917ab4a58..bcd5bfd8e 100644\n--- a/src/plone/restapi/tests/test_permissions.py\n+++ b/src/plone/restapi/tests/test_permissions.py\n@@ -55,10 +55,8 @@ def test_unauthorized_if_missing_permission(self):\n \n response = self.api_session.get(self.portal_url)\n self.assertEqual(response.status_code, 401)\n- self.assertDictContainsSubset(\n- {\n- "type": "Unauthorized",\n- "message": "Missing \'plone.restapi: Use REST API\' permission",\n- },\n- response.json(),\n+ data = response.json()\n+ self.assertEqual(data["type"], "Unauthorized")\n+ self.assertEqual(\n+ data["message"], "Missing \'plone.restapi: Use REST API\' permission"\n )\ndiff --git a/src/plone/restapi/tests/test_search.py b/src/plone/restapi/tests/test_search.py\nindex 2f66ecdba..e4ddb4c38 100644\n--- a/src/plone/restapi/tests/test_search.py\n+++ b/src/plone/restapi/tests/test_search.py\n@@ -247,15 +247,11 @@ def test_partial_metadata_retrieval(self):\n }\n response = self.api_session.get("/@search", params=query)\n \n- self.assertDictContainsSubset(\n- {\n- "@id": self.portal_url + "/folder/doc",\n- "title": "Lorem Ipsum",\n- "portal_type": "DXTestDocument",\n- "review_state": "private",\n- },\n- response.json()["items"][0],\n- )\n+ item = response.json()["items"][0]\n+ self.assertEqual(item["@id"], self.portal_url + "/folder/doc")\n+ self.assertEqual(item["title"], "Lorem Ipsum")\n+ self.assertEqual(item["portal_type"], "DXTestDocument")\n+ self.assertEqual(item["review_state"], "private")\n \n def test_full_metadata_retrieval(self):\n query = {"SearchableText": "lorem", "metadata_fields": "_all"}\ndiff --git a/src/plone/restapi/tests/test_serializer_catalog.py b/src/plone/restapi/tests/test_serializer_catalog.py\nindex 453680f02..67b0604ae 100644\n--- a/src/plone/restapi/tests/test_serializer_catalog.py\n+++ b/src/plone/restapi/tests/test_serializer_catalog.py\n@@ -55,8 +55,8 @@ def test_lazy_map_serialization(self):\n lazy_map = self.catalog()\n results = getMultiAdapter((lazy_map, self.request), ISerializeToJson)()\n \n- self.assertDictContainsSubset({"@id": "http://nohost"}, results)\n- self.assertDictContainsSubset({"items_total": 3}, results)\n+ self.assertEqual(results["@id"], "http://nohost")\n+ self.assertEqual(results["items_total"], 3)\n self.assertEqual(3, len(results["items"]))\n \n @unittest.skipIf(HAS_PLONE_6, "... before it was not")\n@@ -65,8 +65,8 @@ def test_lazy_map_serialization_plone5(self):\n lazy_map = self.catalog()\n results = getMultiAdapter((lazy_map, self.request), ISerializeToJson)()\n \n- self.assertDictContainsSubset({"@id": "http://nohost"}, results)\n- self.assertDictContainsSubset({"items_total": 2}, results)\n+ self.assertEqual(results["@id"], "http://nohost")\n+ self.assertEqual(results["items_total"], 2)\n self.assertEqual(2, len(results["items"]))\n \n def test_lazy_map_serialization_with_fullobjects(self):\n@@ -76,45 +76,43 @@ def test_lazy_map_serialization_with_fullobjects(self):\n fullobjects=True\n )\n \n- self.assertDictContainsSubset({"@id": "http://nohost"}, results)\n- self.assertDictContainsSubset({"items_total": 1}, results)\n+ self.assertEqual(results["@id"], "http://nohost")\n+ self.assertEqual(results["items_total"], 1)\n self.assertEqual(1, len(results["items"]))\n result_item = results["items"][0]\n \n- self.assertDictContainsSubset(\n- {\n- "@id": "http://nohost/plone/my-folder/my-document",\n- "@type": "Document",\n- "changeNote": "",\n- "contributors": [],\n- "creators": ["test_user_1_"],\n+ expected = {\n+ "@id": "http://nohost/plone/my-folder/my-document",\n+ "@type": "Document",\n+ "changeNote": "",\n+ "contributors": [],\n+ "creators": ["test_user_1_"],\n+ "description": "",\n+ "effective": None,\n+ "exclude_from_nav": False,\n+ "expires": None,\n+ "id": "my-document",\n+ "is_folderish": False,\n+ "language": "",\n+ "layout": "document_view",\n+ "parent": {\n+ "@id": "http://nohost/plone/my-folder",\n+ "@type": "Folder",\n+ "type_title": "Folder",\n "description": "",\n- "effective": None,\n- "exclude_from_nav": False,\n- "expires": None,\n- "id": "my-document",\n- "is_folderish": False,\n- "language": "",\n- "layout": "document_view",\n- "parent": {\n- "@id": "http://nohost/plone/my-folder",\n- "@type": "Folder",\n- "type_title": "Folder",\n- "description": "",\n- "review_state": "private",\n- "title": "My Folder",\n- },\n- "relatedItems": [],\n "review_state": "private",\n- "rights": "",\n- "subjects": [],\n- "table_of_contents": None,\n- "text": None,\n- "title": "My Document",\n- "version": "current",\n+ "title": "My Folder",\n },\n- result_item,\n- )\n+ "relatedItems": [],\n+ "review_state": "private",\n+ "rights": "",\n+ "subjects": [],\n+ "table_of_contents": None,\n+ "text": None,\n+ "title": "My Document",\n+ "version": "current",\n+ }\n+ self.assertEqual(result_item, {**result_item, **expected})\n \n def test_brain_summary_representation(self):\n lazy_map = self.catalog(path="/plone/my-folder/my-document")\ndiff --git a/src/plone/restapi/tests/test_services.py b/src/plone/restapi/tests/test_services.py\nindex dac51df7c..1a0944efd 100644\n--- a/src/plone/restapi/tests/test_services.py\n+++ b/src/plone/restapi/tests/test_services.py\n@@ -111,10 +111,8 @@ def test_get_news_item(self):\n self.assertEqual(\n "This is an image caption.", response.json()["image_caption"]\n )\n- self.assertDictContainsSubset(\n- {"download": self.portal_url + f"/news1/@@images/{scale_url_uuid}.png"},\n- response.json()["image"],\n- )\n+ url = self.portal_url + f"/news1/@@images/{scale_url_uuid}.png"\n+ self.assertEqual(response.json()["image"]["download"], url)\n \n def test_get_folder(self):\n self.portal.invokeFactory("Folder", id="folder1", title="My Folder")\ndiff --git a/src/plone/restapi/tests/test_services_querystring.py b/src/plone/restapi/tests/test_services_querystring.py\nindex 1203ab633..8ccb0f7eb 100644\n--- a/src/plone/restapi/tests/test_services_querystring.py\n+++ b/src/plone/restapi/tests/test_services_querystring.py\n@@ -80,13 +80,8 @@ def test_endpoint_inlines_vocabularies(self):\n indexes = response.json()["indexes"]\n idx = indexes["review_state"]\n \n- self.assertDictContainsSubset(\n- {\n- "title": "Review state",\n- "vocabulary": "plone.app.vocabularies.WorkflowStates",\n- },\n- idx,\n- )\n+ self.assertEqual(idx["title"], "Review state")\n+ self.assertEqual(idx["vocabulary"], "plone.app.vocabularies.WorkflowStates")\n \n expected_vocab_values = {\n "external": {"title": "Externally visible [external]"},\n@@ -110,15 +105,13 @@ def test_endpoint_inlines_operators(self):\n indexes = response.json()["indexes"]\n idx = indexes["isDefaultPage"]\n \n- self.assertDictContainsSubset(\n- {\n- "title": "Default Page",\n- "operations": [\n- "plone.app.querystring.operation.boolean.isTrue",\n- "plone.app.querystring.operation.boolean.isFalse",\n- ],\n- },\n- idx,\n+ self.assertEqual(idx["title"], "Default Page")\n+ self.assertEqual(\n+ idx["operations"],\n+ [\n+ "plone.app.querystring.operation.boolean.isTrue",\n+ "plone.app.querystring.operation.boolean.isFalse",\n+ ],\n )\n \n expected_operators = {\n@@ -144,16 +137,14 @@ def test_endpoint_includes_widgets_for_operators(self):\n indexes = response.json()["indexes"]\n idx = indexes["getObjPositionInParent"]\n \n- self.assertDictContainsSubset(\n- {\n- "title": "Order in folder",\n- "operations": [\n- "plone.app.querystring.operation.int.is",\n- "plone.app.querystring.operation.int.lessThan",\n- "plone.app.querystring.operation.int.largerThan",\n- ],\n- },\n- idx,\n+ self.assertEqual(idx["title"], "Order in folder")\n+ self.assertEqual(\n+ idx["operations"],\n+ [\n+ "plone.app.querystring.operation.int.is",\n+ "plone.app.querystring.operation.int.lessThan",\n+ "plone.app.querystring.operation.int.largerThan",\n+ ],\n )\n \n ops = idx["operators"]\n' | ||
|