diff --git a/src/plone/restapi/tests/http-examples/jwt_logged_in.resp b/src/plone/restapi/tests/http-examples/jwt_logged_in.resp index 7e8dca4f6c..dd45f70974 100644 --- a/src/plone/restapi/tests/http-examples/jwt_logged_in.resp +++ b/src/plone/restapi/tests/http-examples/jwt_logged_in.resp @@ -14,6 +14,9 @@ Content-Type: application/json }, "navigation": { "@id": "http://localhost:55001/plone/@navigation" + }, + "navroot": { + "@id": "http://localhost:55001/plone/@navroot" } }, "@id": "http://localhost:55001/plone/", diff --git a/src/plone/restapi/tests/http-examples/navroot_lang_content_get.resp b/src/plone/restapi/tests/http-examples/navroot_lang_content_get.resp index a6ff5e542e..e02abd7099 100644 --- a/src/plone/restapi/tests/http-examples/navroot_lang_content_get.resp +++ b/src/plone/restapi/tests/http-examples/navroot_lang_content_get.resp @@ -8,9 +8,6 @@ Content-Type: application/json "actions": { "@id": "http://localhost:55001/plone/en/@actions" }, - "aliases": { - "@id": "http://localhost:55001/plone/en/@aliases" - }, "breadcrumbs": { "@id": "http://localhost:55001/plone/en/@breadcrumbs" }, @@ -54,16 +51,14 @@ Content-Type: application/json "@type": "LIF", "description": "", "review_state": "published", - "title": "Assets", - "type_title": "Language Independent Folder" + "title": "Assets" }, { "@id": "http://localhost:55001/plone/en/test-document", "@type": "Document", "description": "", "review_state": "private", - "title": "Test document", - "type_title": "Page" + "title": "Test document" } ], "items_total": 2, @@ -78,24 +73,19 @@ Content-Type: application/json "@id": "http://localhost:55001/plone/de", "@type": "LRF", "description": "", - "title": "Deutsch", - "type_title": "Language Root Folder" + "title": "Deutsch" }, "parent": { "@id": "http://localhost:55001/plone", "@type": "Plone Site", "description": "", - "title": "Plone site", - "type_title": "Plone Site" + "title": "Plone site" }, "previous_item": {}, "review_state": "published", "rights": "", "subjects": [], "title": "English", - "type_title": "Language Root Folder", - "version": "current", - "working_copy": null, - "working_copy_of": null + "version": "current" } } diff --git a/src/plone/restapi/tests/http-examples/navroot_lang_folder_get.resp b/src/plone/restapi/tests/http-examples/navroot_lang_folder_get.resp index 0b506e7ac3..bc30c5d934 100644 --- a/src/plone/restapi/tests/http-examples/navroot_lang_folder_get.resp +++ b/src/plone/restapi/tests/http-examples/navroot_lang_folder_get.resp @@ -8,9 +8,6 @@ Content-Type: application/json "actions": { "@id": "http://localhost:55001/plone/en/@actions" }, - "aliases": { - "@id": "http://localhost:55001/plone/en/@aliases" - }, "breadcrumbs": { "@id": "http://localhost:55001/plone/en/@breadcrumbs" }, @@ -54,16 +51,14 @@ Content-Type: application/json "@type": "LIF", "description": "", "review_state": "published", - "title": "Assets", - "type_title": "Language Independent Folder" + "title": "Assets" }, { "@id": "http://localhost:55001/plone/en/test-document", "@type": "Document", "description": "", "review_state": "private", - "title": "Test document", - "type_title": "Page" + "title": "Test document" } ], "items_total": 2, @@ -78,24 +73,19 @@ Content-Type: application/json "@id": "http://localhost:55001/plone/de", "@type": "LRF", "description": "", - "title": "Deutsch", - "type_title": "Language Root Folder" + "title": "Deutsch" }, "parent": { "@id": "http://localhost:55001/plone", "@type": "Plone Site", "description": "", - "title": "Plone site", - "type_title": "Plone Site" + "title": "Plone site" }, "previous_item": {}, "review_state": "published", "rights": "", "subjects": [], "title": "English", - "type_title": "Language Root Folder", - "version": "current", - "working_copy": null, - "working_copy_of": null + "version": "current" } } diff --git a/src/plone/restapi/tests/http-examples/navroot_site_get.resp b/src/plone/restapi/tests/http-examples/navroot_site_get.resp index 8773250024..5879b552e3 100644 --- a/src/plone/restapi/tests/http-examples/navroot_site_get.resp +++ b/src/plone/restapi/tests/http-examples/navroot_site_get.resp @@ -8,9 +8,6 @@ Content-Type: application/json "actions": { "@id": "http://localhost:55001/plone/@actions" }, - "aliases": { - "@id": "http://localhost:55001/plone/@aliases" - }, "breadcrumbs": { "@id": "http://localhost:55001/plone/@breadcrumbs" }, @@ -22,26 +19,13 @@ Content-Type: application/json }, "navroot": { "@id": "http://localhost:55001/plone/@navroot" - }, - "types": { - "@id": "http://localhost:55001/plone/@types" - }, - "workflow": { - "@id": "http://localhost:55001/plone/@workflow" } }, - "@id": "http://localhost:55001/plone", + "@id": "http://localhost:55001/plone/@navroot", "@type": "Plone Site", - "UID": "55c25ebc220d400393574f37d648727c", - "allow_discussion": null, - "contributors": [], - "creators": [ - "admin" - ], + "blocks": {}, + "blocks_layout": {}, "description": "", - "effective": null, - "exclude_from_nav": false, - "expires": null, "id": "plone", "is_folderish": true, "items": [ @@ -50,51 +34,32 @@ Content-Type: application/json "@type": "LRF", "description": "", "review_state": "published", - "title": "English", - "type_title": "Language Root Folder" + "title": "English" }, { "@id": "http://localhost:55001/plone/de", "@type": "LRF", "description": "", "review_state": "published", - "title": "Deutsch", - "type_title": "Language Root Folder" + "title": "Deutsch" }, { "@id": "http://localhost:55001/plone/es", "@type": "LRF", "description": "", "review_state": "published", - "title": "Espa\u00f1ol", - "type_title": "Language Root Folder" + "title": "Espa\u00f1ol" }, { "@id": "http://localhost:55001/plone/fr", "@type": "LRF", "description": "", "review_state": null, - "title": "Fran\u00e7ais", - "type_title": "Language Root Folder" + "title": "Fran\u00e7ais" } ], "items_total": 4, - "language": { - "title": "English", - "token": "en" - }, - "lock": { - "locked": false, - "stealable": true - }, "parent": {}, - "relatedItems": [], - "review_state": null, - "rights": "", - "subjects": [], - "table_of_contents": null, - "text": null, - "title": "Plone site", - "type_title": "Plone Site" + "title": "Plone site" } } diff --git a/src/plone/restapi/tests/http-examples/site_get_expand_lang_folder.resp b/src/plone/restapi/tests/http-examples/site_get_expand_lang_folder.resp index cbdda29f64..d5c1a0f186 100644 --- a/src/plone/restapi/tests/http-examples/site_get_expand_lang_folder.resp +++ b/src/plone/restapi/tests/http-examples/site_get_expand_lang_folder.resp @@ -6,9 +6,6 @@ Content-Type: application/json "actions": { "@id": "http://localhost:55001/plone/en/@actions" }, - "aliases": { - "@id": "http://localhost:55001/plone/en/@aliases" - }, "breadcrumbs": { "@id": "http://localhost:55001/plone/en/@breadcrumbs" }, @@ -25,9 +22,6 @@ Content-Type: application/json "actions": { "@id": "http://localhost:55001/plone/en/@actions" }, - "aliases": { - "@id": "http://localhost:55001/plone/en/@aliases" - }, "breadcrumbs": { "@id": "http://localhost:55001/plone/en/@breadcrumbs" }, @@ -71,16 +65,14 @@ Content-Type: application/json "@type": "LIF", "description": "", "review_state": "published", - "title": "Assets", - "type_title": "Language Independent Folder" + "title": "Assets" }, { "@id": "http://localhost:55001/plone/en/test-document", "@type": "Document", "description": "", "review_state": "private", - "title": "Test document", - "type_title": "Page" + "title": "Test document" } ], "items_total": 2, @@ -95,25 +87,20 @@ Content-Type: application/json "@id": "http://localhost:55001/plone/de", "@type": "LRF", "description": "", - "title": "Deutsch", - "type_title": "Language Root Folder" + "title": "Deutsch" }, "parent": { "@id": "http://localhost:55001/plone", "@type": "Plone Site", "description": "", - "title": "Plone site", - "type_title": "Plone Site" + "title": "Plone site" }, "previous_item": {}, "review_state": "published", "rights": "", "subjects": [], "title": "English", - "type_title": "Language Root Folder", - "version": "current", - "working_copy": null, - "working_copy_of": null + "version": "current" } }, "translations": { @@ -147,16 +134,14 @@ Content-Type: application/json "@type": "LIF", "description": "", "review_state": "published", - "title": "Assets", - "type_title": "Language Independent Folder" + "title": "Assets" }, { "@id": "http://localhost:55001/plone/en/test-document", "@type": "Document", "description": "", "review_state": "private", - "title": "Test document", - "type_title": "Page" + "title": "Test document" } ], "items_total": 2, @@ -171,23 +156,18 @@ Content-Type: application/json "@id": "http://localhost:55001/plone/de", "@type": "LRF", "description": "", - "title": "Deutsch", - "type_title": "Language Root Folder" + "title": "Deutsch" }, "parent": { "@id": "http://localhost:55001/plone", "@type": "Plone Site", "description": "", - "title": "Plone site", - "type_title": "Plone Site" + "title": "Plone site" }, "previous_item": {}, "review_state": "published", "rights": "", "subjects": [], "title": "English", - "type_title": "Language Root Folder", - "version": "current", - "working_copy": null, - "working_copy_of": null + "version": "current" } diff --git a/src/plone/restapi/tests/http-examples/site_get_expand_lang_folder_content.resp b/src/plone/restapi/tests/http-examples/site_get_expand_lang_folder_content.resp index fdd9f28b64..32745d5534 100644 --- a/src/plone/restapi/tests/http-examples/site_get_expand_lang_folder_content.resp +++ b/src/plone/restapi/tests/http-examples/site_get_expand_lang_folder_content.resp @@ -6,9 +6,6 @@ Content-Type: application/json "actions": { "@id": "http://localhost:55001/plone/en/test-document/@actions" }, - "aliases": { - "@id": "http://localhost:55001/plone/en/test-document/@aliases" - }, "breadcrumbs": { "@id": "http://localhost:55001/plone/en/test-document/@breadcrumbs" }, @@ -25,9 +22,6 @@ Content-Type: application/json "actions": { "@id": "http://localhost:55001/plone/en/@actions" }, - "aliases": { - "@id": "http://localhost:55001/plone/en/@aliases" - }, "breadcrumbs": { "@id": "http://localhost:55001/plone/en/@breadcrumbs" }, @@ -71,16 +65,14 @@ Content-Type: application/json "@type": "LIF", "description": "", "review_state": "published", - "title": "Assets", - "type_title": "Language Independent Folder" + "title": "Assets" }, { "@id": "http://localhost:55001/plone/en/test-document", "@type": "Document", "description": "", "review_state": "private", - "title": "Test document", - "type_title": "Page" + "title": "Test document" } ], "items_total": 2, @@ -95,25 +87,20 @@ Content-Type: application/json "@id": "http://localhost:55001/plone/de", "@type": "LRF", "description": "", - "title": "Deutsch", - "type_title": "Language Root Folder" + "title": "Deutsch" }, "parent": { "@id": "http://localhost:55001/plone", "@type": "Plone Site", "description": "", - "title": "Plone site", - "type_title": "Plone Site" + "title": "Plone site" }, "previous_item": {}, "review_state": "published", "rights": "", "subjects": [], "title": "English", - "type_title": "Language Root Folder", - "version": "current", - "working_copy": null, - "working_copy_of": null + "version": "current" } }, "translations": { @@ -158,15 +145,13 @@ Content-Type: application/json "@type": "LRF", "description": "", "review_state": "published", - "title": "English", - "type_title": "Language Root Folder" + "title": "English" }, "previous_item": { "@id": "http://localhost:55001/plone/en/assets", "@type": "LIF", "description": "", - "title": "Assets", - "type_title": "Language Independent Folder" + "title": "Assets" }, "relatedItems": [], "review_state": "private", @@ -175,9 +160,6 @@ Content-Type: application/json "table_of_contents": null, "text": null, "title": "Test document", - "type_title": "Page", "version": "current", - "versioning_enabled": true, - "working_copy": null, - "working_copy_of": null + "versioning_enabled": true } diff --git a/src/plone/restapi/tests/http-examples/site_get_expand_navroot.resp b/src/plone/restapi/tests/http-examples/site_get_expand_navroot.resp index 00a8775fa7..b28d008a7a 100644 --- a/src/plone/restapi/tests/http-examples/site_get_expand_navroot.resp +++ b/src/plone/restapi/tests/http-examples/site_get_expand_navroot.resp @@ -6,9 +6,6 @@ Content-Type: application/json "actions": { "@id": "http://localhost:55001/plone/@actions" }, - "aliases": { - "@id": "http://localhost:55001/plone/@aliases" - }, "breadcrumbs": { "@id": "http://localhost:55001/plone/@breadcrumbs" }, @@ -25,9 +22,6 @@ Content-Type: application/json "actions": { "@id": "http://localhost:55001/plone/@actions" }, - "aliases": { - "@id": "http://localhost:55001/plone/@aliases" - }, "breadcrumbs": { "@id": "http://localhost:55001/plone/@breadcrumbs" }, @@ -39,26 +33,13 @@ Content-Type: application/json }, "navroot": { "@id": "http://localhost:55001/plone/@navroot" - }, - "types": { - "@id": "http://localhost:55001/plone/@types" - }, - "workflow": { - "@id": "http://localhost:55001/plone/@workflow" } }, - "@id": "http://localhost:55001/plone", + "@id": "http://localhost:55001/plone/?expand=navroot", "@type": "Plone Site", - "UID": "55c25ebc220d400393574f37d648727c", - "allow_discussion": null, - "contributors": [], - "creators": [ - "admin" - ], + "blocks": {}, + "blocks_layout": {}, "description": "", - "effective": null, - "exclude_from_nav": false, - "expires": null, "id": "plone", "is_folderish": true, "items": [ @@ -67,73 +48,41 @@ Content-Type: application/json "@type": "LRF", "description": "", "review_state": "published", - "title": "English", - "type_title": "Language Root Folder" + "title": "English" }, { "@id": "http://localhost:55001/plone/de", "@type": "LRF", "description": "", "review_state": "published", - "title": "Deutsch", - "type_title": "Language Root Folder" + "title": "Deutsch" }, { "@id": "http://localhost:55001/plone/es", "@type": "LRF", "description": "", "review_state": "published", - "title": "Espa\u00f1ol", - "type_title": "Language Root Folder" + "title": "Espa\u00f1ol" }, { "@id": "http://localhost:55001/plone/fr", "@type": "LRF", "description": "", "review_state": null, - "title": "Fran\u00e7ais", - "type_title": "Language Root Folder" + "title": "Fran\u00e7ais" } ], "items_total": 4, - "language": { - "title": "English", - "token": "en" - }, - "lock": { - "locked": false, - "stealable": true - }, "parent": {}, - "relatedItems": [], - "review_state": null, - "rights": "", - "subjects": [], - "table_of_contents": null, - "text": null, - "title": "Plone site", - "type_title": "Plone Site" + "title": "Plone site" } - }, - "types": { - "@id": "http://localhost:55001/plone/@types" - }, - "workflow": { - "@id": "http://localhost:55001/plone/@workflow" } }, - "@id": "http://localhost:55001/plone", + "@id": "http://localhost:55001/plone/?expand=navroot", "@type": "Plone Site", - "UID": "55c25ebc220d400393574f37d648727c", - "allow_discussion": null, - "contributors": [], - "creators": [ - "admin" - ], + "blocks": {}, + "blocks_layout": {}, "description": "", - "effective": null, - "exclude_from_nav": false, - "expires": null, "id": "plone", "is_folderish": true, "items": [ @@ -142,50 +91,31 @@ Content-Type: application/json "@type": "LRF", "description": "", "review_state": "published", - "title": "English", - "type_title": "Language Root Folder" + "title": "English" }, { "@id": "http://localhost:55001/plone/de", "@type": "LRF", "description": "", "review_state": "published", - "title": "Deutsch", - "type_title": "Language Root Folder" + "title": "Deutsch" }, { "@id": "http://localhost:55001/plone/es", "@type": "LRF", "description": "", "review_state": "published", - "title": "Espa\u00f1ol", - "type_title": "Language Root Folder" + "title": "Espa\u00f1ol" }, { "@id": "http://localhost:55001/plone/fr", "@type": "LRF", "description": "", "review_state": null, - "title": "Fran\u00e7ais", - "type_title": "Language Root Folder" + "title": "Fran\u00e7ais" } ], "items_total": 4, - "language": { - "title": "English", - "token": "en" - }, - "lock": { - "locked": false, - "stealable": true - }, "parent": {}, - "relatedItems": [], - "review_state": null, - "rights": "", - "subjects": [], - "table_of_contents": null, - "text": null, - "title": "Plone site", - "type_title": "Plone Site" + "title": "Plone site" } diff --git a/src/plone/restapi/tests/http-examples/siteroot.resp b/src/plone/restapi/tests/http-examples/siteroot.resp index 4c00477092..a528d73376 100644 --- a/src/plone/restapi/tests/http-examples/siteroot.resp +++ b/src/plone/restapi/tests/http-examples/siteroot.resp @@ -14,6 +14,9 @@ Content-Type: application/json }, "navigation": { "@id": "http://localhost:55001/plone/@navigation" + }, + "navroot": { + "@id": "http://localhost:55001/plone/@navroot" } }, "@id": "http://localhost:55001/plone", diff --git a/src/plone/restapi/tests/test_documentation.py b/src/plone/restapi/tests/test_documentation.py index 5912a1f0f3..6145f9fba0 100644 --- a/src/plone/restapi/tests/test_documentation.py +++ b/src/plone/restapi/tests/test_documentation.py @@ -115,7 +115,9 @@ def pretty_json(data): def save_request_and_response_for_docs( name, response, response_text_override="", request_text_override="" ): - save_request_for_docs(name, response, request_text_override=request_text_override) + save_request_for_docs( + name, response, request_text_override=request_text_override + ) filename = "{}/{}".format(base_path, "%s.resp" % name) with open(filename, "w", **open_kw) as resp: status = response.status_code @@ -166,7 +168,10 @@ def save_request_for_docs(name, response, request_text_override=""): req.write("\n") # Pretty print JSON request body - if content_type == "application/json" and not request_text_override: + if ( + content_type == "application/json" + and not request_text_override + ): json_body = json.loads(response.request.body) body = pretty_json(json_body) # Make sure Content-Length gets updated, just in case we @@ -261,8 +266,12 @@ def create_folder(self): folder = self.portal["folder"] folder.title = "My Folder" folder.description = u"This is a folder with two documents" - folder.invokeFactory("Document", id="doc1", title="A document within a folder") - folder.invokeFactory("Document", id="doc2", title="A document within a folder") + folder.invokeFactory( + "Document", id="doc1", title="A document within a folder" + ) + folder.invokeFactory( + "Document", id="doc2", title="A document within a folder" + ) return folder def test_documentation_content_crud(self): @@ -281,7 +290,8 @@ def test_documentation_content_crud(self): save_request_and_response_for_docs("content_get", response) response = self.api_session.get( - folder.absolute_url() + "?metadata_fields=UID&metadata_fields=Creator" + folder.absolute_url() + + "?metadata_fields=UID&metadata_fields=Creator" ) save_request_and_response_for_docs("content_get_folder", response) @@ -295,7 +305,9 @@ def test_documentation_content_crud(self): headers={"Prefer": "return=representation"}, json={"title": "My New Document Title"}, ) - save_request_and_response_for_docs("content_patch_representation", response) + save_request_and_response_for_docs( + "content_patch_representation", response + ) transaction.commit() response = self.api_session.delete(document.absolute_url()) @@ -322,7 +334,9 @@ def test_documentation_news_item(self): transaction.commit() with patch.object(storage, "uuid4", return_value="uuid1"): - response = self.api_session.get(self.portal.newsitem.absolute_url()) + response = self.api_session.get( + self.portal.newsitem.absolute_url() + ) save_request_and_response_for_docs("newsitem", response) def test_documentation_event(self): @@ -382,7 +396,9 @@ def test_documentation_folder(self): def test_documentation_collection(self): self.portal.invokeFactory("Collection", id="collection") self.portal.collection.title = "My Collection" - self.portal.collection.description = u"This is a collection with two documents" + self.portal.collection.description = ( + u"This is a collection with two documents" + ) self.portal.collection.query = [ { "i": "portal_type", @@ -399,7 +415,9 @@ def test_documentation_collection(self): def test_documentation_collection_fullobjects(self): self.portal.invokeFactory("Collection", id="collection") self.portal.collection.title = "My Collection" - self.portal.collection.description = u"This is a collection with two documents" + self.portal.collection.description = ( + u"This is a collection with two documents" + ) self.portal.collection.query = [ { "i": "portal_type", @@ -430,7 +448,9 @@ def test_documentation_search(self): def test_documentation_search_options(self): self.portal.invokeFactory("Folder", id="folder1", title="Folder 1") - self.portal.folder1.invokeFactory("Folder", id="folder2", title="Folder 2") + self.portal.folder1.invokeFactory( + "Folder", id="folder2", title="Folder 2" + ) transaction.commit() query = { "sort_on": "path", @@ -442,9 +462,13 @@ def test_documentation_search_options(self): def test_documentation_search_multiple_paths(self): self.portal.invokeFactory("Folder", id="folder1", title="Folder 1") - self.portal.folder1.invokeFactory("Document", id="doc1", title="Lorem Ipsum") + self.portal.folder1.invokeFactory( + "Document", id="doc1", title="Lorem Ipsum" + ) self.portal.invokeFactory("Folder", id="folder2", title="Folder 2") - self.portal.folder2.invokeFactory("Document", id="doc2", title="Lorem Ipsum") + self.portal.folder2.invokeFactory( + "Document", id="doc2", title="Lorem Ipsum" + ) transaction.commit() query = { "sort_on": "path", @@ -532,7 +556,9 @@ def test_documentation_types_document_crud(self): "description": "Contact information", }, ) - save_request_and_response_for_docs("types_document_post_fieldset", response) + save_request_and_response_for_docs( + "types_document_post_fieldset", response + ) # Add field response = self.api_session.post( @@ -552,9 +578,7 @@ def test_documentation_types_document_crud(self): document_schema_re = re.compile( r"^plone.dexterity.schema.generated.plone_5_\d*_2_\d*_0_Document$" ) - stable_behavior = ( - "plone.dexterity.schema.generated.plone_5_1234567890_2_123456_0_Document" - ) + stable_behavior = "plone.dexterity.schema.generated.plone_5_1234567890_2_123456_0_Document" json_response = response.json() response_text_override = "" behavior = json_response.get("behavior") @@ -587,7 +611,9 @@ def test_documentation_types_document_crud(self): # Get fieldset response = self.api_session.get("/@types/Document/contact_info") - save_request_and_response_for_docs("types_document_get_fieldset", response) + save_request_and_response_for_docs( + "types_document_get_fieldset", response + ) # Get field response = self.api_session.get("/@types/Document/author_email") @@ -618,7 +644,9 @@ def test_documentation_types_document_crud(self): } }, ) - save_request_and_response_for_docs("types_document_patch_properites", response) + save_request_and_response_for_docs( + "types_document_patch_properites", response + ) # Change field tab / order response = self.api_session.patch( @@ -633,7 +661,9 @@ def test_documentation_types_document_crud(self): ] }, ) - save_request_and_response_for_docs("types_document_patch_fieldsets", response) + save_request_and_response_for_docs( + "types_document_patch_fieldsets", response + ) # Update fieldset settings response = self.api_session.patch( @@ -644,7 +674,9 @@ def test_documentation_types_document_crud(self): "fields": ["author_email"], }, ) - save_request_and_response_for_docs("types_document_patch_fieldset", response) + save_request_and_response_for_docs( + "types_document_patch_fieldset", response + ) # Update field settings response = self.api_session.patch( @@ -657,7 +689,9 @@ def test_documentation_types_document_crud(self): "required": True, }, ) - save_request_and_response_for_docs("types_document_patch_field", response) + save_request_and_response_for_docs( + "types_document_patch_field", response + ) doc_json["layouts"] = ["thumbnail_view", "table_view"] doc_json["fieldsets"] = [ @@ -712,13 +746,17 @@ def test_documentation_types_document_crud(self): response = self.api_session.delete( "/@types/Document/author_email", ) - save_request_and_response_for_docs("types_document_delete_field", response) + save_request_and_response_for_docs( + "types_document_delete_field", response + ) # Remove fieldset response = self.api_session.delete( "/@types/Document/contact_info", ) - save_request_and_response_for_docs("types_document_delete_fieldset", response) + save_request_and_response_for_docs( + "types_document_delete_fieldset", response + ) def test_documentation_jwt_login(self): self.portal.acl_users.jwt_auth._secret = "secret" @@ -797,7 +835,9 @@ def test_documentation_batching(self): transaction.commit() query = {"sort_on": "path"} - response = self.api_session.get("/folder/@search?b_size=5", params=query) + response = self.api_session.get( + "/folder/@search?b_size=5", params=query + ) save_request_and_response_for_docs("batching", response) def test_documentation_users(self): @@ -1051,7 +1091,9 @@ def test_documentation_users_update_portrait(self): response_get = self.api_session.get("/@users/noam", json=payload) save_request_and_response_for_docs("users_update_portrait", response) - save_request_and_response_for_docs("users_update_portrait_get", response_get) + save_request_and_response_for_docs( + "users_update_portrait_get", response_get + ) def test_documentation_users_update_portrait_with_scale(self): payload = { @@ -1067,7 +1109,9 @@ def test_documentation_users_update_portrait_with_scale(self): transaction.commit() response = self.api_session.patch("/@users/noam", json=payload) - save_request_and_response_for_docs("users_update_portrait_scale", response) + save_request_and_response_for_docs( + "users_update_portrait_scale", response + ) def test_documentation_users_delete(self): properties = { @@ -1245,7 +1289,9 @@ def test_documentation_navigation_tree(self): id=u"fourthlevelfolder", title=u"Fourth Level Folder", ) - createContentInContainer(folder, u"Document", id=u"doc1", title=u"A document") + createContentInContainer( + folder, u"Document", id=u"doc1", title=u"A document" + ) transaction.commit() response = self.api_session.get( @@ -1279,7 +1325,9 @@ def test_documentation_contextnavigation(self): id=u"fourthlevelfolder", title=u"Fourth Level Folder", ) - createContentInContainer(folder, u"Document", id=u"doc1", title=u"A document") + createContentInContainer( + folder, u"Document", id=u"doc1", title=u"A document" + ) transaction.commit() response = self.api_session.get( "{}/folder/@contextnavigation".format(self.portal.absolute_url()) @@ -1302,7 +1350,9 @@ def test_documentation_principals(self): description=properties["description"], ) transaction.commit() - response = self.api_session.get("/@principals", params={"search": "ploneteam"}) + response = self.api_session.get( + "/@principals", params={"search": "ploneteam"} + ) save_request_and_response_for_docs("principals", response) def test_documentation_copy(self): @@ -1312,7 +1362,9 @@ def test_documentation_copy(self): save_request_and_response_for_docs("copy", response) def test_documentation_copy_multiple(self): - newsitem = self.portal[self.portal.invokeFactory("News Item", id="newsitem")] + newsitem = self.portal[ + self.portal.invokeFactory("News Item", id="newsitem") + ] newsitem.title = "My News Item" transaction.commit() @@ -1351,7 +1403,8 @@ def test_documentation_vocabularies_get_fields(self): def test_documentation_vocabularies_get_filtered_by_title(self): response = self.api_session.get( - "/@vocabularies/plone.app.vocabularies.ReallyUserFriendlyTypes?" "title=doc" + "/@vocabularies/plone.app.vocabularies.ReallyUserFriendlyTypes?" + "title=doc" ) save_request_and_response_for_docs( "vocabularies_get_filtered_by_title", response @@ -1374,7 +1427,9 @@ def test_documentation_sources_get(self): title=u"DX Document", ) transaction.commit() - response = self.api_session.get("/doc/@sources/test_choice_with_source") + response = self.api_session.get( + "/doc/@sources/test_choice_with_source" + ) save_request_and_response_for_docs("sources_get", response) def test_documentation_sharing_folder_get(self): @@ -1499,7 +1554,9 @@ def clean_final_url(response, _id="document-2016-10-21"): save_request_and_response_for_docs("tusupload_patch", response) # HEAD ask for much the server has - response = self.api_session.head(upload_url, headers={"Tus-Resumable": "1.0.0"}) + response = self.api_session.head( + upload_url, headers={"Tus-Resumable": "1.0.0"} + ) clean_upload_url(response) save_request_and_response_for_docs("tusupload_head", response) @@ -1515,7 +1572,9 @@ def clean_final_url(response, _id="document-2016-10-21"): ) clean_upload_url(response) clean_final_url(response) - save_request_and_response_for_docs("tusupload_patch_finalized", response) + save_request_and_response_for_docs( + "tusupload_patch_finalized", response + ) def test_tusreplace_post_patch(self): self.portal.invokeFactory("File", id="myfile") @@ -1581,7 +1640,9 @@ def test_locking_lock_nonstealable_and_timeout(self): b' "0.684672730996-0.25195226375-00105A989226:1477076400.000"', # noqa response.content, ) - save_request_and_response_for_docs("lock_nonstealable_timeout", response) + save_request_and_response_for_docs( + "lock_nonstealable_timeout", response + ) def test_locking_unlock(self): url = "{}/@lock".format(self.document.absolute_url()) @@ -1637,7 +1698,9 @@ def test_querystring_get(self): def test_querystringsearch_post(self): url = "/@querystring-search" - self.portal.invokeFactory("Document", "testdocument", title="Test Document") + self.portal.invokeFactory( + "Document", "testdocument", title="Test Document" + ) transaction.commit() response = self.api_session.post( @@ -1698,14 +1761,20 @@ def create_document(self): def test_translate_messages_types(self): response = self.api_session.get("/@types") - save_request_and_response_for_docs("translated_messages_types", response) + save_request_and_response_for_docs( + "translated_messages_types", response + ) def test_translate_messages_types_folder(self): response = self.api_session.get("/@types/Folder") - save_request_and_response_for_docs("translated_messages_types_folder", response) + save_request_and_response_for_docs( + "translated_messages_types_folder", response + ) def test_translate_messages_object_workflow(self): - response = self.api_session.get("{}/@workflow".format(self.document.id)) + response = self.api_session.get( + "{}/@workflow".format(self.document.id) + ) save_request_and_response_for_docs( "translated_messages_object_workflow", response ) @@ -1786,7 +1855,9 @@ def clean_comment_id_from_urls(response, _id="123456"): # and the body if response.request.body: - response.request.body = re.sub(pattern_bytes, repl, response.request.body) + response.request.body = re.sub( + pattern_bytes, repl, response.request.body + ) # and the response if response.content: @@ -1827,7 +1898,9 @@ def test_comments_add_root(self): def test_comments_add_sub(self): # Add a reply - url = "{}/@comments/{}".format(self.document.absolute_url(), self.comment_id) + url = "{}/@comments/{}".format( + self.document.absolute_url(), self.comment_id + ) payload = {"text": "My reply"} response = self.api_session.post(url, json=payload) @@ -1835,14 +1908,18 @@ def test_comments_add_sub(self): save_request_and_response_for_docs("comments_add_sub", response) def test_comments_update(self): - url = "{}/@comments/{}".format(self.document.absolute_url(), self.comment_id) + url = "{}/@comments/{}".format( + self.document.absolute_url(), self.comment_id + ) payload = {"text": "My NEW comment"} response = self.api_session.patch(url, json=payload) self.clean_comment_id_from_urls(response) save_request_and_response_for_docs("comments_update", response) def test_comments_delete(self): - url = "{}/@comments/{}".format(self.document.absolute_url(), self.comment_id) + url = "{}/@comments/{}".format( + self.document.absolute_url(), self.comment_id + ) response = self.api_session.delete(url) self.clean_comment_id_from_urls(response) save_request_and_response_for_docs("comments_delete", response) @@ -1853,7 +1930,9 @@ def test_roles_get(self): save_request_and_response_for_docs("roles", response) def test_documentation_expansion(self): - response = self.api_session.get("/front-page?expand=breadcrumbs,workflow") + response = self.api_session.get( + "/front-page?expand=breadcrumbs,workflow" + ) save_request_and_response_for_docs("expansion", response) @@ -1872,7 +1951,9 @@ def test_controlpanels_get_item(self): def test_controlpanels_get_dexterity(self): response = self.api_session.get("/@controlpanels/dexterity-types") - save_request_and_response_for_docs("controlpanels_get_dexterity", response) + save_request_and_response_for_docs( + "controlpanels_get_dexterity", response + ) def test_controlpanels_crud_dexterity(self): # POST @@ -1891,7 +1972,9 @@ def test_controlpanels_crud_dexterity(self): response = self.api_session.get( "/@controlpanels/dexterity-types/my_custom_content_type" ) - save_request_and_response_for_docs("controlpanels_get_dexterity_item", response) + save_request_and_response_for_docs( + "controlpanels_get_dexterity_item", response + ) # PATCH response = self.api_session.patch( @@ -1933,10 +2016,18 @@ def setUp(self): # When we have tried to apply it for LRFs we have had several # utility registration problems. # - setattr(self.portal.en, "_plone.uuid", "00000000000000000000000000000001") - setattr(self.portal.es, "_plone.uuid", "00000000000000000000000000000002") - setattr(self.portal.fr, "_plone.uuid", "00000000000000000000000000000003") - setattr(self.portal.de, "_plone.uuid", "00000000000000000000000000000004") + setattr( + self.portal.en, "_plone.uuid", "00000000000000000000000000000001" + ) + setattr( + self.portal.es, "_plone.uuid", "00000000000000000000000000000002" + ) + setattr( + self.portal.fr, "_plone.uuid", "00000000000000000000000000000003" + ) + setattr( + self.portal.de, "_plone.uuid", "00000000000000000000000000000004" + ) en_id = self.portal["en"].invokeFactory( "Document", id="test-document", title="Test document" @@ -1958,7 +2049,11 @@ def test_documentation_translations_post(self): def test_documentation_translations_post_by_id(self): response = self.api_session.post( "{}/@translations".format(self.en_content.absolute_url()), - json={"id": self.es_content.absolute_url().replace(self.portal_url, "")}, + json={ + "id": self.es_content.absolute_url().replace( + self.portal_url, "" + ) + }, ) save_request_and_response_for_docs("translations_post_by_id", response) @@ -1967,10 +2062,14 @@ def test_documentation_translations_post_by_uid(self): "{}/@translations".format(self.en_content.absolute_url()), json={"id": self.es_content.UID()}, ) - save_request_and_response_for_docs("translations_post_by_uid", response) + save_request_and_response_for_docs( + "translations_post_by_uid", response + ) def test_documentation_translations_get(self): - ITranslationManager(self.en_content).register_translation("es", self.es_content) + ITranslationManager(self.en_content).register_translation( + "es", self.es_content + ) transaction.commit() response = self.api_session.get( @@ -1980,7 +2079,9 @@ def test_documentation_translations_get(self): save_request_and_response_for_docs("translations_get", response) def test_documentation_translations_delete(self): - ITranslationManager(self.en_content).register_translation("es", self.es_content) + ITranslationManager(self.en_content).register_translation( + "es", self.es_content + ) transaction.commit() response = self.api_session.delete( "{}/@translations".format(self.en_content.absolute_url()), @@ -1999,7 +2100,9 @@ def test_documentation_translations_link_on_post(self): "language": "de", }, ) - save_request_and_response_for_docs("translations_link_on_post", response) + save_request_and_response_for_docs( + "translations_link_on_post", response + ) def test_documentation_translation_locator(self): response = self.api_session.get( @@ -2021,7 +2124,9 @@ def test_site_navroot_language_folder_get(self): def test_site_navroot_language_content_get(self): response = self.api_session.get("/en/test-document/@navroot") - save_request_and_response_for_docs("navroot_lang_content_get", response) + save_request_and_response_for_docs( + "navroot_lang_content_get", response + ) def test_site_expansion_navroot(self): response = self.api_session.get("?expand=navroot") @@ -2029,7 +2134,9 @@ def test_site_expansion_navroot(self): def test_site_expansion_navroot_language_folder(self): response = self.api_session.get("/en?expand=navroot") - save_request_and_response_for_docs("site_get_expand_lang_folder", response) + save_request_and_response_for_docs( + "site_get_expand_lang_folder", response + ) def test_site_expansion_navroot_language_folder_content(self): response = self.api_session.get("/en/test-document?expand=navroot")