From 0527f84d3029c66346b47d0d90e5d7b484e56ad0 Mon Sep 17 00:00:00 2001 From: "Jens W. Klein" Date: Sun, 8 May 2022 00:30:48 +0200 Subject: [PATCH] move tests to restapi --- plone/app/caching/testing.py | 12 -- .../tests/test_profile_with_caching_proxy.py | 118 ------------------ .../test_profile_without_caching_proxy.py | 115 ----------------- setup.py | 1 - 4 files changed, 246 deletions(-) diff --git a/plone/app/caching/testing.py b/plone/app/caching/testing.py index b4f6919..4546a5c 100644 --- a/plone/app/caching/testing.py +++ b/plone/app/caching/testing.py @@ -6,7 +6,6 @@ from plone.app.testing import PloneSandboxLayer from plone.cachepurging.interfaces import IPurger from plone.protect.authenticator import _getKeyring -from plone.restapi.testing import PLONE_RESTAPI_DX_PAM_FIXTURE from plone.testing import z2 from zope.component import getUtility from zope.component import provideUtility @@ -63,13 +62,7 @@ class PloneAppCaching(PloneAppCachingBase): defaultBases = (PLONE_APP_CONTENTTYPES_FIXTURE,) -class PloneAppCachingRestAPI(PloneAppCachingBase): - - defaultBases = (PLONE_RESTAPI_DX_PAM_FIXTURE,) - - PLONE_APP_CACHING_FIXTURE = PloneAppCaching() -PLONE_APP_CACHING_RESTAPI_FIXTURE = PloneAppCachingRestAPI() PLONE_APP_CACHING_INTEGRATION_TESTING = IntegrationTesting( bases=(PLONE_APP_CACHING_FIXTURE,), name="PloneAppCaching:Integration", @@ -79,11 +72,6 @@ class PloneAppCachingRestAPI(PloneAppCachingBase): name="PloneAppCaching:Functional", ) -PLONE_APP_CACHING_FUNCTIONAL_RESTAPI_TESTING = FunctionalTesting( - bases=(PLONE_APP_CACHING_RESTAPI_FIXTURE, z2.ZSERVER_FIXTURE), - name="PloneAppCachingRestAPI:Functional", -) - def getToken(username): ring = _getKeyring(username) diff --git a/plone/app/caching/tests/test_profile_with_caching_proxy.py b/plone/app/caching/tests/test_profile_with_caching_proxy.py index b2ff4a6..1e2d1f7 100644 --- a/plone/app/caching/tests/test_profile_with_caching_proxy.py +++ b/plone/app/caching/tests/test_profile_with_caching_proxy.py @@ -1,6 +1,5 @@ from io import BytesIO from plone.app.caching.interfaces import IPloneCacheSettings -from plone.app.caching.testing import PLONE_APP_CACHING_FUNCTIONAL_RESTAPI_TESTING from plone.app.caching.testing import PLONE_APP_CACHING_FUNCTIONAL_TESTING from plone.app.caching.tests.test_utils import normalize_etag from plone.app.caching.tests.test_utils import stable_now @@ -17,7 +16,6 @@ from plone.cachepurging.interfaces import IPurger from plone.caching.interfaces import ICacheSettings from plone.registry.interfaces import IRegistry -from plone.restapi.testing import RelativeSession from plone.testing.z2 import Browser from Products.CMFCore.FSFile import FSFile from Products.CMFCore.utils import getToolByName @@ -603,119 +601,3 @@ def test_stable_resources(self): # What is the best way to test this? # Maybe not important since the RR test exercises the same code? pass - - -class TestProfileWithCachingRestAPI(unittest.TestCase): - """This test aims to exercise the caching operations expected from the - `with-caching-proxy` profile for supported restapi calls. - """ - - layer = PLONE_APP_CACHING_FUNCTIONAL_RESTAPI_TESTING - - def setUp(self): - self.app = self.layer["app"] - self.portal = self.layer["portal"] - - test_css = FSFile( - "test.css", os.path.join(os.path.dirname(__file__), "test.css") - ) - self.portal.portal_skins.custom._setOb("test.css", test_css) - - setRequest(self.portal.REQUEST) - - applyProfile(self.portal, "plone.app.caching:with-caching-proxy") - - self.registry = getUtility(IRegistry) - - self.cacheSettings = self.registry.forInterface(ICacheSettings) - self.cachePurgingSettings = self.registry.forInterface(ICachePurgingSettings) - self.ploneCacheSettings = self.registry.forInterface(IPloneCacheSettings) - - self.cacheSettings.enabled = True - - self.purger = getUtility(IPurger) - self.purger.reset() - - # some test content - setRoles(self.portal, TEST_USER_ID, ("Manager",)) - - self.portal.invokeFactory("Folder", "f1") - self.portal["f1"].title = "Folder one" - self.portal.portal_workflow.doActionFor(self.portal["f1"], "publish") - - self.portal["f1"].invokeFactory("Folder", "f2") - self.portal["f1"]["f2"].title = "Folder one sub one" - self.portal.portal_workflow.doActionFor(self.portal["f1"]["f2"], "publish") - - self.portal.invokeFactory("Collection", "c") - self.portal["c"].title = "A Collection" - self.portal.portal_workflow.doActionFor(self.portal["c"], "publish") - - transaction.commit() - - # restapi test session - self.api_session = RelativeSession(self.layer["portal"].absolute_url()) - self.api_session.headers.update({"Accept": "application/json"}) - - def test_restapi_actions(self): - # plone.content.dynamic for plone.restapi.services.actions.get.ActionsGet - response = self.api_session.get("/f1/f2/@actions") - self.assertEqual(response.status_code, 200) - self.assertEqual(response.headers["X-Cache-Rule"], "plone.content.dynamic") - self.assertEqual( - response.headers["X-Cache-Operation"], "plone.app.caching.terseCaching" - ) - - def test_restapi_breadcrumbs(self): - # plone.content.dynamic for plone.restapi.services.breadcrumbs.get.BreadcrumbsGet - response = self.api_session.get("/f1/f2/@breadcrumbs") - self.assertEqual(response.status_code, 200) - self.assertEqual(response.headers["X-Cache-Rule"], "plone.content.dynamic") - self.assertEqual( - response.headers["X-Cache-Operation"], "plone.app.caching.terseCaching" - ) - - def test_restapi_comments(self): - # plone.content.itemView for plone.restapi.services.discussion.conversation.CommentsGet - response = self.api_session.get("/f1/f2/@comments") - self.assertEqual(response.status_code, 200) - self.assertEqual(response.headers["X-Cache-Rule"], "plone.content.itemView") - self.assertEqual( - response.headers["X-Cache-Operation"], "plone.app.caching.weakCaching" - ) - - def test_restapi_content(self): - # plone.content.dynamic for plone.restapi.services.content.get.ContentGet - response = self.api_session.get("/f1/f2") - self.assertEqual(response.status_code, 200) - self.assertEqual(response.headers["X-Cache-Rule"], "plone.content.dynamic") - self.assertEqual( - response.headers["X-Cache-Operation"], "plone.app.caching.terseCaching" - ) - - def test_restapi_navigation(self): - # plone.content.dynamic for plone.restapi.services.navigation.get.NavigationGet - response = self.api_session.get("/f1/f2/@navigation") - self.assertEqual(response.status_code, 200) - self.assertEqual(response.headers["X-Cache-Rule"], "plone.content.dynamic") - self.assertEqual( - response.headers["X-Cache-Operation"], "plone.app.caching.terseCaching" - ) - - def test_restapi_querystring(self): - # plone.content.dynamic for plone.restapi.services.querystring.get.QueryStringGet - response = self.api_session.get("/@querystring") - self.assertEqual(response.status_code, 200) - self.assertEqual(response.headers["X-Cache-Rule"], "plone.content.dynamic") - self.assertEqual( - response.headers["X-Cache-Operation"], "plone.app.caching.terseCaching" - ) - - def test_restapi_search(self): - # plone.content.dynamic for plone.restapi.services.search.get.SearchGet - response = self.api_session.get("/@search") - self.assertEqual(response.status_code, 200) - self.assertEqual(response.headers["X-Cache-Rule"], "plone.content.dynamic") - self.assertEqual( - response.headers["X-Cache-Operation"], "plone.app.caching.terseCaching" - ) diff --git a/plone/app/caching/tests/test_profile_without_caching_proxy.py b/plone/app/caching/tests/test_profile_without_caching_proxy.py index 0032d55..342aacb 100644 --- a/plone/app/caching/tests/test_profile_without_caching_proxy.py +++ b/plone/app/caching/tests/test_profile_without_caching_proxy.py @@ -1,5 +1,4 @@ from plone.app.caching.interfaces import IPloneCacheSettings -from plone.app.caching.testing import PLONE_APP_CACHING_FUNCTIONAL_RESTAPI_TESTING from plone.app.caching.testing import PLONE_APP_CACHING_FUNCTIONAL_TESTING from plone.app.caching.tests.test_utils import normalize_etag from plone.app.caching.tests.test_utils import stable_now @@ -13,7 +12,6 @@ from plone.cachepurging.interfaces import ICachePurgingSettings from plone.caching.interfaces import ICacheSettings from plone.registry.interfaces import IRegistry -from plone.restapi.testing import RelativeSession from plone.testing.z2 import Browser from Products.CMFCore.FSFile import FSFile from Products.CMFCore.utils import getToolByName @@ -508,116 +506,3 @@ def test_stable_resources(self): # What is the best way to test this? # Maybe not important since the RR test exercises the same code? pass - - -class TestProfileWithoutCachingRestAPI(unittest.TestCase): - """This test aims to exercise the caching operations expected from the - `without-caching-proxy` profile for supported restapi calls. - """ - - layer = PLONE_APP_CACHING_FUNCTIONAL_RESTAPI_TESTING - - def setUp(self): - self.app = self.layer["app"] - self.portal = self.layer["portal"] - - test_css = FSFile( - "test.css", os.path.join(os.path.dirname(__file__), "test.css") - ) - self.portal.portal_skins.custom._setOb("test.css", test_css) - - setRequest(self.portal.REQUEST) - - applyProfile(self.portal, "plone.app.caching:without-caching-proxy") - - self.registry = getUtility(IRegistry) - - self.cacheSettings = self.registry.forInterface(ICacheSettings) - self.cachePurgingSettings = self.registry.forInterface(ICachePurgingSettings) - self.ploneCacheSettings = self.registry.forInterface(IPloneCacheSettings) - - self.cacheSettings.enabled = True - - # some test content - setRoles(self.portal, TEST_USER_ID, ("Manager",)) - - self.portal.invokeFactory("Folder", "f1") - self.portal["f1"].title = "Folder one" - self.portal.portal_workflow.doActionFor(self.portal["f1"], "publish") - - self.portal["f1"].invokeFactory("Folder", "f2") - self.portal["f1"]["f2"].title = "Folder one sub one" - self.portal.portal_workflow.doActionFor(self.portal["f1"]["f2"], "publish") - - self.portal.invokeFactory("Collection", "c") - self.portal["c"].title = "A Collection" - self.portal.portal_workflow.doActionFor(self.portal["c"], "publish") - - transaction.commit() - - # restapi test session - self.api_session = RelativeSession(self.layer["portal"].absolute_url()) - self.api_session.headers.update({"Accept": "application/json"}) - - def test_restapi_actions(self): - # plone.content.dynamic for plone.restapi.services.actions.get.ActionsGet - response = self.api_session.get("/f1/f2/@actions") - self.assertEqual(response.status_code, 200) - self.assertEqual(response.headers["X-Cache-Rule"], "plone.content.dynamic") - self.assertEqual( - response.headers["X-Cache-Operation"], "plone.app.caching.terseCaching" - ) - - def test_restapi_breadcrumbs(self): - # plone.content.dynamic for plone.restapi.services.breadcrumbs.get.BreadcrumbsGet - response = self.api_session.get("/f1/f2/@breadcrumbs") - self.assertEqual(response.status_code, 200) - self.assertEqual(response.headers["X-Cache-Rule"], "plone.content.dynamic") - self.assertEqual( - response.headers["X-Cache-Operation"], "plone.app.caching.terseCaching" - ) - - def test_restapi_comments(self): - # plone.content.itemView for plone.restapi.services.discussion.conversation.CommentsGet - response = self.api_session.get("/f1/f2/@comments") - self.assertEqual(response.status_code, 200) - self.assertEqual(response.headers["X-Cache-Rule"], "plone.content.itemView") - self.assertEqual( - response.headers["X-Cache-Operation"], "plone.app.caching.weakCaching" - ) - - def test_restapi_content(self): - # plone.content.dynamic for plone.restapi.services.content.get.ContentGet - response = self.api_session.get("/f1/f2") - self.assertEqual(response.status_code, 200) - self.assertEqual(response.headers["X-Cache-Rule"], "plone.content.dynamic") - self.assertEqual( - response.headers["X-Cache-Operation"], "plone.app.caching.terseCaching" - ) - - def test_restapi_navigation(self): - # plone.content.dynamic for plone.restapi.services.navigation.get.NavigationGet - response = self.api_session.get("/f1/f2/@navigation") - self.assertEqual(response.status_code, 200) - self.assertEqual(response.headers["X-Cache-Rule"], "plone.content.dynamic") - self.assertEqual( - response.headers["X-Cache-Operation"], "plone.app.caching.terseCaching" - ) - - def test_restapi_querystring(self): - # plone.content.dynamic for plone.restapi.services.querystring.get.QueryStringGet - response = self.api_session.get("/@querystring") - self.assertEqual(response.status_code, 200) - self.assertEqual(response.headers["X-Cache-Rule"], "plone.content.dynamic") - self.assertEqual( - response.headers["X-Cache-Operation"], "plone.app.caching.terseCaching" - ) - - def test_restapi_search(self): - # plone.content.dynamic for plone.restapi.services.search.get.SearchGet - response = self.api_session.get("/@search") - self.assertEqual(response.status_code, 200) - self.assertEqual(response.headers["X-Cache-Rule"], "plone.content.dynamic") - self.assertEqual( - response.headers["X-Cache-Operation"], "plone.app.caching.terseCaching" - ) diff --git a/setup.py b/setup.py index da96778..2d7e8de 100644 --- a/setup.py +++ b/setup.py @@ -44,7 +44,6 @@ "test": [ "plone.app.contenttypes[test]", "plone.app.testing", - "plone.restapi[test]", ] }, entry_points="""