Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cekk committed Dec 5, 2024
1 parent 96ab8fe commit 6019fc3
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/redturtle/volto/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
Expand Down Expand Up @@ -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")
Expand Down
39 changes: 39 additions & 0 deletions src/redturtle/volto/tests/test_noacquisition.py
Original file line number Diff line number Diff line change
@@ -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)
32 changes: 32 additions & 0 deletions src/redturtle/volto/tests/test_patch_absolutize_path.py
Original file line number Diff line number Diff line change
@@ -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))

0 comments on commit 6019fc3

Please sign in to comment.