Skip to content

Commit

Permalink
add test for behavior schema
Browse files Browse the repository at this point in the history
  • Loading branch information
davisagli committed May 21, 2024
1 parent 0f40f35 commit 160f019
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
4 changes: 4 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@
"zestreleaser.towncrier",
"plone.app.contenttypes[test]",
"plone.app.testing",
"plone.restapi[test]",
# Undeclared dependency of plone.restapi,
# can be removed after next release
"plone.app.iterate",
"pytest",
"pytest-cov",
"pytest-plone>=0.2.0",
Expand Down
4 changes: 4 additions & 0 deletions src/kitconcept/seo/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ def setUpZope(self, app, configurationContext):
# Load any other ZCML that is required for your tests.
# The z3c.autoinclude feature is disabled in the Plone fixture base
# layer.
import plone.restapi

self.loadZCML(package=kitconcept.seo)
self.loadZCML(package=plone.restapi)

def setUpPloneSite(self, portal):
applyProfile(portal, "kitconcept.seo:default")
applyProfile(portal, "plone.restapi:default")


FIXTURE = Layer()
Expand Down
12 changes: 12 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
from kitconcept.seo.testing import FUNCTIONAL_TESTING
from kitconcept.seo.testing import INTEGRATION_TESTING
from plone.app.testing import SITE_OWNER_NAME
from plone.app.testing import SITE_OWNER_PASSWORD
from plone.restapi.testing import RelativeSession
from pytest_plone import fixtures_factory
import pytest


pytest_plugins = ["pytest_plone"]
Expand All @@ -14,3 +18,11 @@
)
)
)


@pytest.fixture
def manager_plone_client(functional):
portal = functional["portal"]
api_session = RelativeSession(f"{portal.absolute_url()}/++api++")
api_session.auth = (SITE_OWNER_NAME, SITE_OWNER_PASSWORD)
return api_session
23 changes: 23 additions & 0 deletions tests/test_behavior.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
def test_seo_behavior_fields(manager_plone_client):
# Enable behavior for pages
resp = manager_plone_client.patch(
"/@controlpanels/dexterity-types/Document", json={"kitconcept.seo": True}
)

# Check schema
schema = manager_plone_client.get("/@types/Document").json()
assert schema["fieldsets"][-1] == {
"behavior": "plone",
"description": "",
"fields": [
"seo_title",
"seo_description",
"seo_noindex",
"seo_canonical_url",
"opengraph_title",
"opengraph_description",
"opengraph_image",
],
"id": "seo",
"title": "SEO",
}

0 comments on commit 160f019

Please sign in to comment.