diff --git a/src/redturtle/volto/testing.py b/src/redturtle/volto/testing.py index c7719e8..b0ca7dc 100644 --- a/src/redturtle/volto/testing.py +++ b/src/redturtle/volto/testing.py @@ -10,6 +10,7 @@ import collective.volto.gdprcookie import collective.volto.sitesettings +import experimental.noacquisition import kitconcept.seo import plone.app.caching import plone.restapi @@ -31,6 +32,7 @@ def setUpZope(self, app, configurationContext): self.loadZCML(package=plone.volto) self.loadZCML(package=plone.app.caching) self.loadZCML(package=kitconcept.seo) + self.loadZCML(package=experimental.noacquisition) def setUpPloneSite(self, portal): applyProfile(portal, "plone.app.caching:default") @@ -75,6 +77,7 @@ def setUpZope(self, app, configurationContext): self.loadZCML(package=redturtle.volto) self.loadZCML(package=plone.app.caching) self.loadZCML(package=kitconcept.seo) + self.loadZCML(package=experimental.noacquisition) def setUpPloneSite(self, portal): applyProfile(portal, "plone.app.caching:default") diff --git a/src/redturtle/volto/tests/test_noacquisition.py b/src/redturtle/volto/tests/test_noacquisition.py new file mode 100644 index 0000000..3799f3e --- /dev/null +++ b/src/redturtle/volto/tests/test_noacquisition.py @@ -0,0 +1,39 @@ +from plone import api +from plone.app.testing import setRoles +from plone.app.testing import SITE_OWNER_NAME +from plone.app.testing import SITE_OWNER_PASSWORD +from plone.app.testing import TEST_USER_ID +from plone.restapi.testing import RelativeSession +from redturtle.volto.testing import REDTURTLE_VOLTO_API_FUNCTIONAL_TESTING +from transaction import commit + +import unittest + + +class TestNoAcquisition(unittest.TestCase): + layer = REDTURTLE_VOLTO_API_FUNCTIONAL_TESTING + + def setUp(self): + self.app = self.layer["app"] + self.portal = self.layer["portal"] + self.request = self.layer["request"] + self.portal_url = self.portal.absolute_url() + setRoles(self.portal, TEST_USER_ID, ["Manager"]) + + self.api_session = RelativeSession(self.portal_url) + self.api_session.headers.update({"Accept": "application/json"}) + self.api_session.auth = (SITE_OWNER_NAME, SITE_OWNER_PASSWORD) + + self.document = api.content.create( + container=self.portal, type="Document", title="aaa" + ) + + self.child = api.content.create( + container=self.document, type="Document", title="bbb" + ) + + commit() + + def test_with_noacquisition_enabled_get_not_found(self): + response = self.api_session.get(f"{self.document.absolute_url()}/aaa/aaa/bbb") + self.assertEqual(response.status_code, 404) diff --git a/src/redturtle/volto/tests/test_patch_absolutize_path.py b/src/redturtle/volto/tests/test_patch_absolutize_path.py new file mode 100644 index 0000000..ecfefaf --- /dev/null +++ b/src/redturtle/volto/tests/test_patch_absolutize_path.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +"""Setup tests for this package.""" +from plone import api +from plone.app.testing import setRoles +from plone.app.testing import TEST_USER_ID +from Products.CMFPlone.controlpanel.browser.redirects import absolutize_path +from redturtle.volto.testing import REDTURTLE_VOLTO_INTEGRATION_TESTING + +import unittest + + +class TestAbsolutizePath(unittest.TestCase): + """ """ + + layer = REDTURTLE_VOLTO_INTEGRATION_TESTING + + def setUp(self): + self.app = self.layer["app"] + self.portal = self.layer["portal"] + self.portal_url = self.portal.absolute_url() + setRoles(self.portal, TEST_USER_ID, ["Manager"]) + + self.foo = api.content.create( + container=self.portal, + type="Document", + title="Foo", + ) + + def test_patched_method_allows_to_create_alias_with_same_path(self): + # by default will return + # ('/plone/foo/foo', 'Cannot use a working path as alternative url.') + self.assertEqual(absolutize_path("/foo/foo"), ("/plone/foo/foo", None))