diff --git a/src/plone/restapi/tests/test_batching.py b/src/plone/restapi/tests/test_batching.py index 810846298c..3e809ebabc 100644 --- a/src/plone/restapi/tests/test_batching.py +++ b/src/plone/restapi/tests/test_batching.py @@ -455,7 +455,7 @@ def test_first_link_contained(self): self.request.form["b_size"] = 10 batch = HypermediaBatch(self.request, items) - self.assertDictContainsSubset({"first": "http://nohost?b_start=0"}, batch.links) + self.assertEqual(batch.links["first"], "http://nohost?b_start=0") def test_first_link_preserves_list_like_querystring_params(self): items = list(range(1, 26)) @@ -478,14 +478,14 @@ def test_last_link_contained(self): self.request.form["b_size"] = 10 batch = HypermediaBatch(self.request, items) - self.assertDictContainsSubset({"last": "http://nohost?b_start=20"}, batch.links) + self.assertEqual(batch.links["last"], "http://nohost?b_start=20") def test_next_link_contained_if_necessary(self): items = list(range(1, 26)) self.request.form["b_size"] = 10 batch = HypermediaBatch(self.request, items) - self.assertDictContainsSubset({"next": "http://nohost?b_start=10"}, batch.links) + self.assertEqual(batch.links["next"], "http://nohost?b_start=10") def test_next_link_omitted_on_last_page(self): items = list(range(1, 26)) @@ -503,7 +503,7 @@ def test_prev_link_contained_if_necessary(self): self.request.form["b_size"] = 10 self.request.form["b_start"] = 20 batch = HypermediaBatch(self.request, items) - self.assertDictContainsSubset({"prev": "http://nohost?b_start=10"}, batch.links) + self.assertEqual(batch.links["prev"], "http://nohost?b_start=10") def test_prev_link_omitted_on_first_page(self): items = list(range(1, 26)) diff --git a/src/plone/restapi/tests/test_permissions.py b/src/plone/restapi/tests/test_permissions.py index 917ab4a588..bcd5bfd8e7 100644 --- a/src/plone/restapi/tests/test_permissions.py +++ b/src/plone/restapi/tests/test_permissions.py @@ -55,10 +55,8 @@ def test_unauthorized_if_missing_permission(self): response = self.api_session.get(self.portal_url) self.assertEqual(response.status_code, 401) - self.assertDictContainsSubset( - { - "type": "Unauthorized", - "message": "Missing 'plone.restapi: Use REST API' permission", - }, - response.json(), + data = response.json() + self.assertEqual(data["type"], "Unauthorized") + self.assertEqual( + data["message"], "Missing 'plone.restapi: Use REST API' permission" ) diff --git a/src/plone/restapi/tests/test_search.py b/src/plone/restapi/tests/test_search.py index 2f66ecdba9..e4ddb4c38d 100644 --- a/src/plone/restapi/tests/test_search.py +++ b/src/plone/restapi/tests/test_search.py @@ -247,15 +247,11 @@ def test_partial_metadata_retrieval(self): } response = self.api_session.get("/@search", params=query) - self.assertDictContainsSubset( - { - "@id": self.portal_url + "/folder/doc", - "title": "Lorem Ipsum", - "portal_type": "DXTestDocument", - "review_state": "private", - }, - response.json()["items"][0], - ) + item = response.json()["items"][0] + self.assertEqual(item["@id"], self.portal_url + "/folder/doc") + self.assertEqual(item["title"], "Lorem Ipsum") + self.assertEqual(item["portal_type"], "DXTestDocument") + self.assertEqual(item["review_state"], "private") def test_full_metadata_retrieval(self): query = {"SearchableText": "lorem", "metadata_fields": "_all"} diff --git a/src/plone/restapi/tests/test_serializer_catalog.py b/src/plone/restapi/tests/test_serializer_catalog.py index 453680f02c..90abb5a0ae 100644 --- a/src/plone/restapi/tests/test_serializer_catalog.py +++ b/src/plone/restapi/tests/test_serializer_catalog.py @@ -55,8 +55,8 @@ def test_lazy_map_serialization(self): lazy_map = self.catalog() results = getMultiAdapter((lazy_map, self.request), ISerializeToJson)() - self.assertDictContainsSubset({"@id": "http://nohost"}, results) - self.assertDictContainsSubset({"items_total": 3}, results) + self.assertEqual(results["@id"], "http://nohost") + self.assertEqual(results["@items_total"], 3) self.assertEqual(3, len(results["items"])) @unittest.skipIf(HAS_PLONE_6, "... before it was not") @@ -65,8 +65,8 @@ def test_lazy_map_serialization_plone5(self): lazy_map = self.catalog() results = getMultiAdapter((lazy_map, self.request), ISerializeToJson)() - self.assertDictContainsSubset({"@id": "http://nohost"}, results) - self.assertDictContainsSubset({"items_total": 2}, results) + self.assertEqual(results["@id"], "http://nohost") + self.assertEqual(results["@items_total"], 2) self.assertEqual(2, len(results["items"])) def test_lazy_map_serialization_with_fullobjects(self): @@ -76,45 +76,43 @@ def test_lazy_map_serialization_with_fullobjects(self): fullobjects=True ) - self.assertDictContainsSubset({"@id": "http://nohost"}, results) - self.assertDictContainsSubset({"items_total": 1}, results) + self.assertEqual(results["@id"], "http://nohost") + self.assertEqual(results["@items_total"], 1) self.assertEqual(1, len(results["items"])) result_item = results["items"][0] - self.assertDictContainsSubset( - { - "@id": "http://nohost/plone/my-folder/my-document", - "@type": "Document", - "changeNote": "", - "contributors": [], - "creators": ["test_user_1_"], + expected = { + "@id": "http://nohost/plone/my-folder/my-document", + "@type": "Document", + "changeNote": "", + "contributors": [], + "creators": ["test_user_1_"], + "description": "", + "effective": None, + "exclude_from_nav": False, + "expires": None, + "id": "my-document", + "is_folderish": False, + "language": "", + "layout": "document_view", + "parent": { + "@id": "http://nohost/plone/my-folder", + "@type": "Folder", + "type_title": "Folder", "description": "", - "effective": None, - "exclude_from_nav": False, - "expires": None, - "id": "my-document", - "is_folderish": False, - "language": "", - "layout": "document_view", - "parent": { - "@id": "http://nohost/plone/my-folder", - "@type": "Folder", - "type_title": "Folder", - "description": "", - "review_state": "private", - "title": "My Folder", - }, - "relatedItems": [], "review_state": "private", - "rights": "", - "subjects": [], - "table_of_contents": None, - "text": None, - "title": "My Document", - "version": "current", + "title": "My Folder", }, - result_item, - ) + "relatedItems": [], + "review_state": "private", + "rights": "", + "subjects": [], + "table_of_contents": None, + "text": None, + "title": "My Document", + "version": "current", + } + self.assertEqual(result_item, {**result_item, **expected}) def test_brain_summary_representation(self): lazy_map = self.catalog(path="/plone/my-folder/my-document") diff --git a/src/plone/restapi/tests/test_services.py b/src/plone/restapi/tests/test_services.py index dac51df7ca..8e89bd8b50 100644 --- a/src/plone/restapi/tests/test_services.py +++ b/src/plone/restapi/tests/test_services.py @@ -111,10 +111,8 @@ def test_get_news_item(self): self.assertEqual( "This is an image caption.", response.json()["image_caption"] ) - self.assertDictContainsSubset( - {"download": self.portal_url + f"/news1/@@images/{scale_url_uuid}.png"}, - response.json()["image"], - ) + url = self.portal_url + f"/news1/@@images/{scale_url_uuid}.png" + self.assertEqual(data["download"], url) def test_get_folder(self): self.portal.invokeFactory("Folder", id="folder1", title="My Folder") diff --git a/src/plone/restapi/tests/test_services_querystring.py b/src/plone/restapi/tests/test_services_querystring.py index 1203ab6336..8ccb0f7ebb 100644 --- a/src/plone/restapi/tests/test_services_querystring.py +++ b/src/plone/restapi/tests/test_services_querystring.py @@ -80,13 +80,8 @@ def test_endpoint_inlines_vocabularies(self): indexes = response.json()["indexes"] idx = indexes["review_state"] - self.assertDictContainsSubset( - { - "title": "Review state", - "vocabulary": "plone.app.vocabularies.WorkflowStates", - }, - idx, - ) + self.assertEqual(idx["title"], "Review state") + self.assertEqual(idx["vocabulary"], "plone.app.vocabularies.WorkflowStates") expected_vocab_values = { "external": {"title": "Externally visible [external]"}, @@ -110,15 +105,13 @@ def test_endpoint_inlines_operators(self): indexes = response.json()["indexes"] idx = indexes["isDefaultPage"] - self.assertDictContainsSubset( - { - "title": "Default Page", - "operations": [ - "plone.app.querystring.operation.boolean.isTrue", - "plone.app.querystring.operation.boolean.isFalse", - ], - }, - idx, + self.assertEqual(idx["title"], "Default Page") + self.assertEqual( + idx["operations"], + [ + "plone.app.querystring.operation.boolean.isTrue", + "plone.app.querystring.operation.boolean.isFalse", + ], ) expected_operators = { @@ -144,16 +137,14 @@ def test_endpoint_includes_widgets_for_operators(self): indexes = response.json()["indexes"] idx = indexes["getObjPositionInParent"] - self.assertDictContainsSubset( - { - "title": "Order in folder", - "operations": [ - "plone.app.querystring.operation.int.is", - "plone.app.querystring.operation.int.lessThan", - "plone.app.querystring.operation.int.largerThan", - ], - }, - idx, + self.assertEqual(idx["title"], "Order in folder") + self.assertEqual( + idx["operations"], + [ + "plone.app.querystring.operation.int.is", + "plone.app.querystring.operation.int.lessThan", + "plone.app.querystring.operation.int.largerThan", + ], ) ops = idx["operators"]