From 9217148824c6002f5e2363e80d550c819b97ac17 Mon Sep 17 00:00:00 2001 From: tisto Date: Wed, 18 Oct 2023 11:13:47 +0200 Subject: [PATCH] [fc] Repository: plone.restapi Branch: refs/heads/main Date: 2023-10-18T11:13:47+02:00 Author: Roel Bruggink (jaroel) Commit: https://github.com/plone/plone.restapi/commit/1d899d81b310a5597a4ec61a42d36163e4b4f075 Treat sub-items like items in @linkintegrity (#1714) * Expose the sources + their target instead of just some sources in "breaches" attribute in @linkintegrity endpoint response Signed-off-by: Roel Bruggink <roel@jaroel.nl> * Be explicit about which data we copy Signed-off-by: Roel Bruggink <roel@jaroel.nl> * Fixup tests Signed-off-by: Roel Bruggink <roel@jaroel.nl> * lint Signed-off-by: Roel Bruggink <roel@jaroel.nl> * test_tree_breaches_no_duplicates is conditional * Treat sub-items like items in @linkintegrity endpoint * Add uid only if we haven't seen it * Unpin plone.app.linktegrity * Pin plone.app.linkintegrity explicitly for both Plone 6 and Plone 5.2 * Update CHANGES.rst Co-authored-by: Steve Piercy <web@stevepiercy.com> * Update CHANGES.rst Co-authored-by: Steve Piercy <web@stevepiercy.com> * Update news/1714.bugfix Co-authored-by: Steve Piercy <web@stevepiercy.com> * Update CHANGES.rst Co-authored-by: Steve Piercy <web@stevepiercy.com> * Update CHANGES.rst Co-authored-by: Steve Piercy <web@stevepiercy.com> --------- Signed-off-by: Roel Bruggink <roel@jaroel.nl> Co-authored-by: Timo Stollenwerk <tisto@users.noreply.github.com> Co-authored-by: Steve Piercy <web@stevepiercy.com> Files changed: A news/1714.bugfix M CHANGES.rst M plone-5.2.x.cfg M plone-6.0.x.cfg M src/plone/restapi/services/linkintegrity/get.py M src/plone/restapi/tests/test_services_linkintegrity.py --- last_commit.txt | 114 +++++++++++++++++++++++++++++------------------- 1 file changed, 69 insertions(+), 45 deletions(-) diff --git a/last_commit.txt b/last_commit.txt index a1172f13f4..28ec075cf1 100644 --- a/last_commit.txt +++ b/last_commit.txt @@ -1,48 +1,72 @@ -Repository: plone.api - - -Branch: refs/heads/master -Date: 2023-10-14T13:05:14+02:00 -Author: Gil Forcada Codinachs (gforcada) -Commit: https://github.com/plone/plone.api/commit/3ea0c864e34c9024b5de3d534db7ea0d0f9f9928 - -fix(py3.12): deprecated methods - -Files changed: -M src/plone/api/tests/test_env.py - -b'diff --git a/src/plone/api/tests/test_env.py b/src/plone/api/tests/test_env.py\nindex f18037ce..3086a4d4 100644\n--- a/src/plone/api/tests/test_env.py\n+++ b/src/plone/api/tests/test_env.py\n@@ -514,14 +514,14 @@ def test_plone_version(self):\n from plone.api.env import plone_version\n \n self.assertTrue(isinstance(plone_version(), str))\n- self.assertRegexpMatches(plone_version(), version_regexp)\n+ self.assertRegex(plone_version(), version_regexp)\n \n def test_zope_version(self):\n """Tests that zope_version() returns Zope version."""\n from plone.api.env import zope_version\n \n self.assertTrue(isinstance(zope_version(), str))\n- self.assertRegexpMatches(zope_version(), version_regexp)\n+ self.assertRegex(zope_version(), version_regexp)\n \n def test_adopt_user_different_username(self):\n user = api.user.get(userid=TEST_USER_ID)\n' - -Repository: plone.api - - -Branch: refs/heads/master -Date: 2023-10-14T13:05:14+02:00 -Author: Gil Forcada Codinachs (gforcada) -Commit: https://github.com/plone/plone.api/commit/b26d6e76664299d1a9f2fe5eb58ba8246f5e5b25 - -Add news entry +Repository: plone.restapi + + +Branch: refs/heads/main +Date: 2023-10-18T11:13:47+02:00 +Author: Roel Bruggink (jaroel) +Commit: https://github.com/plone/plone.restapi/commit/1d899d81b310a5597a4ec61a42d36163e4b4f075 + +Treat sub-items like items in @linkintegrity (#1714) + +* Expose the sources + their target instead of just some sources in "breaches" attribute in @linkintegrity endpoint response + +Signed-off-by: Roel Bruggink <roel@jaroel.nl> + +* Be explicit about which data we copy + +Signed-off-by: Roel Bruggink <roel@jaroel.nl> + +* Fixup tests + +Signed-off-by: Roel Bruggink <roel@jaroel.nl> + +* lint + +Signed-off-by: Roel Bruggink <roel@jaroel.nl> + +* test_tree_breaches_no_duplicates is conditional + +* Treat sub-items like items in @linkintegrity endpoint + +* Add uid only if we haven't seen it + +* Unpin plone.app.linktegrity + +* Pin plone.app.linkintegrity explicitly for both Plone 6 and Plone 5.2 + +* Update CHANGES.rst + +Co-authored-by: Steve Piercy <web@stevepiercy.com> + +* Update CHANGES.rst + +Co-authored-by: Steve Piercy <web@stevepiercy.com> + +* Update news/1714.bugfix + +Co-authored-by: Steve Piercy <web@stevepiercy.com> + +* Update CHANGES.rst + +Co-authored-by: Steve Piercy <web@stevepiercy.com> + +* Update CHANGES.rst + +Co-authored-by: Steve Piercy <web@stevepiercy.com> + +--------- + +Signed-off-by: Roel Bruggink <roel@jaroel.nl> +Co-authored-by: Timo Stollenwerk <tisto@users.noreply.github.com> +Co-authored-by: Steve Piercy <web@stevepiercy.com> Files changed: -A news/1.bugfix - -b'diff --git a/news/1.bugfix b/news/1.bugfix\nnew file mode 100644\nindex 00000000..1494e057\n--- /dev/null\n+++ b/news/1.bugfix\n@@ -0,0 +1,2 @@\n+Replace deprecated assert methods.\n+[gforcada]\n' - -Repository: plone.api - - -Branch: refs/heads/master -Date: 2023-10-14T16:15:18+02:00 -Author: Gil Forcada Codinachs (gforcada) -Commit: https://github.com/plone/plone.api/commit/86a2b874b34245a22261f7588c2430eadc2cba3c - -Merge pull request #514 from plone/fix-regex-asserts - -Fix regex asserts - -Files changed: -A news/1.bugfix -M src/plone/api/tests/test_env.py - -b'diff --git a/news/1.bugfix b/news/1.bugfix\nnew file mode 100644\nindex 00000000..1494e057\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/api/tests/test_env.py b/src/plone/api/tests/test_env.py\nindex f18037ce..3086a4d4 100644\n--- a/src/plone/api/tests/test_env.py\n+++ b/src/plone/api/tests/test_env.py\n@@ -514,14 +514,14 @@ def test_plone_version(self):\n from plone.api.env import plone_version\n \n self.assertTrue(isinstance(plone_version(), str))\n- self.assertRegexpMatches(plone_version(), version_regexp)\n+ self.assertRegex(plone_version(), version_regexp)\n \n def test_zope_version(self):\n """Tests that zope_version() returns Zope version."""\n from plone.api.env import zope_version\n \n self.assertTrue(isinstance(zope_version(), str))\n- self.assertRegexpMatches(zope_version(), version_regexp)\n+ self.assertRegex(zope_version(), version_regexp)\n \n def test_adopt_user_different_username(self):\n user = api.user.get(userid=TEST_USER_ID)\n' +A news/1714.bugfix +M CHANGES.rst +M plone-5.2.x.cfg +M plone-6.0.x.cfg +M src/plone/restapi/services/linkintegrity/get.py +M src/plone/restapi/tests/test_services_linkintegrity.py + +b'diff --git a/CHANGES.rst b/CHANGES.rst\nindex 1513cd6cf2..d0f7ce90dd 100644\n--- a/CHANGES.rst\n+++ b/CHANGES.rst\n@@ -461,9 +461,9 @@ Bug fixes:\n \n \n - Added url field to Actions (#817)\n-- Update statictime tests following changes to p.a.disucssion (see \n- https://github.com/plone/plone.app.discussion/pull/204) - [instification] (#1520)\n-- Update @portrait endpoint to use sanitized user id [instification] (#1524)\n+- Updated ``statictime`` tests following changes to ``p.a.discussion`` (see\n+ https://github.com/plone/plone.app.discussion/pull/204). @instification (#1520)\n+- Updated ``@portrait`` endpoint to use sanitized user id. @instification (#1524)\n \n \n 8.31.0 (2022-10-20)\ndiff --git a/news/1714.bugfix b/news/1714.bugfix\nnew file mode 100644\nindex 0000000000..8cdae00d86\n--- /dev/null\n+++ b/news/1714.bugfix\n@@ -0,0 +1 @@\n+Treat sub-items like items in ``@linkintegrity`` endpoint. @jaroel\n\\ No newline at end of file\ndiff --git a/plone-5.2.x.cfg b/plone-5.2.x.cfg\nindex 158b669f23..d2924baf42 100644\n--- a/plone-5.2.x.cfg\n+++ b/plone-5.2.x.cfg\n@@ -7,4 +7,5 @@ extends =\n black = 22.3.0\n \n # we need the newest plone.rest release\n-plone.rest = 3.0.1\n\\ No newline at end of file\n+plone.rest = 3.0.1\n+plone.app.linkintegrity = 3.6.2\ndiff --git a/plone-6.0.x.cfg b/plone-6.0.x.cfg\nindex ad032cc1fd..a882e859f4 100644\n--- a/plone-6.0.x.cfg\n+++ b/plone-6.0.x.cfg\n@@ -15,6 +15,7 @@ zodb-temporary-storage = off\n [versions]\n black = 22.3.0\n pygments = 2.14.0\n+plone.app.linkintegrity = 4.0.3\n robotframework-browser = 17.5.2\n robotframework-assertion-engine = 2.0.0\n robotframework-debuglibrary = 2.3.0\ndiff --git a/src/plone/restapi/services/linkintegrity/get.py b/src/plone/restapi/services/linkintegrity/get.py\nindex 6c6aa7ea05..32a5ecba7d 100644\n--- a/src/plone/restapi/services/linkintegrity/get.py\n+++ b/src/plone/restapi/services/linkintegrity/get.py\n@@ -38,6 +38,9 @@ def reply(self):\n data = getMultiAdapter((item, self.request), ISerializeToJsonSummary)()\n data["breaches"] = []\n for breach in breaches:\n+ if breach["target"]["uid"] not in uids:\n+ uids.append(breach["target"]["uid"])\n+ continue\n for source in breach.get("sources", []):\n # remove unwanted data\n source["@id"] = source["url"]\ndiff --git a/src/plone/restapi/tests/test_services_linkintegrity.py b/src/plone/restapi/tests/test_services_linkintegrity.py\nindex 297843f709..9492796eb5 100644\n--- a/src/plone/restapi/tests/test_services_linkintegrity.py\n+++ b/src/plone/restapi/tests/test_services_linkintegrity.py\n@@ -20,7 +20,6 @@\n \n \n class TestLinkIntegrity(unittest.TestCase):\n-\n layer = PLONE_RESTAPI_BLOCKS_FUNCTIONAL_TESTING\n \n def setUp(self):\n@@ -210,3 +209,164 @@ def test_return_items_total_in_subfolders(self):\n self.assertEqual(result[0]["@id"], level1.absolute_url())\n self.assertEqual(result[0]["breaches"], [])\n self.assertEqual(result[0]["items_total"], 1)\n+\n+ def test_tree_breaches_no_duplicates(self):\n+ # /target_parent/target_child\n+ target_parent = createContentInContainer(\n+ self.portal, "Folder", id="target-parent"\n+ )\n+ target_child = createContentInContainer(\n+ target_parent, "Document", id="target-child"\n+ )\n+ target_parent_uid = IUUID(target_parent)\n+ target_child_uid = IUUID(target_child)\n+\n+ source_a = createContentInContainer(\n+ self.portal,\n+ "Document",\n+ id="source-a",\n+ title="Source A",\n+ blocks={\n+ "block-uuid1": {\n+ "@type": "text",\n+ "text": {\n+ "blocks": [{"text": "some link"}],\n+ "entityMap": {\n+ "0": {\n+ "data": {\n+ "href": f"../resolveuid/{target_parent_uid}",\n+ "rel": "nofollow",\n+ "url": f"../resolveuid/{target_parent_uid}",\n+ },\n+ "mutability": "MUTABLE",\n+ "type": "LINK",\n+ }\n+ },\n+ },\n+ },\n+ "block-uuid2": {\n+ "@type": "text",\n+ "text": {\n+ "blocks": [{"text": "some other link"}],\n+ "entityMap": {\n+ "0": {\n+ "data": {\n+ "href": f"../resolveuid/{target_child_uid}",\n+ "rel": "nofollow",\n+ "url": f"../resolveuid/{target_child_uid}",\n+ },\n+ "mutability": "MUTABLE",\n+ "type": "LINK",\n+ }\n+ },\n+ },\n+ },\n+ },\n+ )\n+\n+ source_b = createContentInContainer(\n+ self.portal,\n+ "Document",\n+ id="source-b",\n+ title="Source B",\n+ blocks={\n+ "block-uuid3": {\n+ "@type": "text",\n+ "text": {\n+ "blocks": [{"text": "some link"}],\n+ "entityMap": {\n+ "0": {\n+ "data": {\n+ "href": f"../resolveuid/{target_parent_uid}",\n+ "rel": "nofollow",\n+ "url": f"../resolveuid/{target_parent_uid}",\n+ },\n+ "mutability": "MUTABLE",\n+ "type": "LINK",\n+ }\n+ },\n+ },\n+ }\n+ },\n+ )\n+\n+ source_c = createContentInContainer(\n+ self.portal,\n+ "Document",\n+ id="source-c",\n+ title="Source C",\n+ blocks={\n+ "block-uuid4": {\n+ "@type": "text",\n+ "text": {\n+ "blocks": [{"text": "some other link"}],\n+ "entityMap": {\n+ "0": {\n+ "data": {\n+ "href": f"../resolveuid/{target_child_uid}",\n+ "rel": "nofollow",\n+ "url": f"../resolveuid/{target_child_uid}",\n+ },\n+ "mutability": "MUTABLE",\n+ "type": "LINK",\n+ }\n+ },\n+ },\n+ },\n+ },\n+ )\n+\n+ transaction.commit()\n+\n+ response = self.api_session.get(\n+ "/@linkintegrity", params={"uids": [target_parent_uid]}\n+ )\n+\n+ results = response.json()\n+ self.assertEqual(\n+ [\n+ {\n+ "@id": target_parent.absolute_url(),\n+ "@type": "Folder",\n+ "breaches": [\n+ {\n+ "@id": source_a.absolute_url(),\n+ "title": "Source A",\n+ "uid": IUUID(source_a),\n+ },\n+ {\n+ "@id": source_b.absolute_url(),\n+ "title": "Source B",\n+ "uid": IUUID(source_b),\n+ },\n+ ],\n+ "description": "",\n+ "items_total": 1,\n+ "review_state": "private",\n+ "title": "",\n+ "type_title": "Folder",\n+ },\n+ {\n+ "@id": target_child.absolute_url(),\n+ "@type": "Document",\n+ "breaches": [\n+ {\n+ "@id": source_a.absolute_url(),\n+ "title": "Source A",\n+ "uid": IUUID(source_a),\n+ },\n+ {\n+ "@id": source_c.absolute_url(),\n+ "title": "Source C",\n+ "uid": IUUID(source_c),\n+ },\n+ ],\n+ "description": "",\n+ "items_total": 0,\n+ "review_state": "private",\n+ "title": "",\n+ "type_title": "Page",\n+ },\n+ ],\n+ results,\n+ )\n'