Skip to content

Commit

Permalink
improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cekk committed Jul 23, 2024
1 parent 267d36e commit 3cfb60f
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/iosanita/contenttypes/events/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"publish": True,
},
{
"id": "sponsor_evento",
"id": "sponsor-evento",
"title": "Sponsor Evento",
"allowed_types": ("Link",),
"publish": True,
Expand Down
7 changes: 7 additions & 0 deletions src/iosanita/contenttypes/tests/test_ct_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,3 +238,10 @@ def test_if_event_has_children_events_is_indexed_as_rassegna(self):
brain = api.content.find(UID=parent.UID())[0]

self.assertTrue(brain.rassegna)

def test_event_default_children(self):
event = api.content.create(container=self.portal, type="Event", title="xxx")

self.assertEqual(
event.keys(), ["immagini", "video", "sponsor-evento", "documenti"]
)
10 changes: 10 additions & 0 deletions src/iosanita/contenttypes/tests/test_ct_persona.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,13 @@ def test_persona_title_composed_also_with_titolo(self):
self.assertIn("dr-doe-john", self.portal.keys())
persona = self.portal["dr-doe-john"]
self.assertEqual(persona.title, "dr. Doe John")

def test_persona_default_children(self):
createContentInContainer(
self.portal, "Persona", nome="John", cognome="Doe", titolo_persona="dr."
)
persona = self.portal["dr-doe-john"]

self.assertEqual(
persona.keys(), ["curriculum-vitae", "multimedia", "altri-documenti"]
)
21 changes: 20 additions & 1 deletion src/iosanita/contenttypes/tests/test_ct_servizio.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
"""Setup tests for this package."""
from iosanita.contenttypes.testing import RESTAPI_TESTING
from iosanita.contenttypes.testing import RESTAPI_TESTING, INTEGRATION_TESTING
from plone import api
from plone.app.testing import setRoles
from plone.app.testing import SITE_OWNER_NAME
Expand Down Expand Up @@ -231,3 +231,22 @@ def test_servizio_fields_ulteriori_informazioni_fieldset(self):
"""
resp = self.api_session.get("@types/Servizio").json()
self.assertEqual(resp["fieldsets"][12]["fields"], ["ulteriori_informazioni"])


class TestServizio(unittest.TestCase):
""""""

layer = 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"])

def test_servizio_default_children(self):
servizio = api.content.create(
container=self.portal, type="Servizio", title="xxx"
)

self.assertEqual(servizio.keys(), ["modulistica", "allegati"])
21 changes: 20 additions & 1 deletion src/iosanita/contenttypes/tests/test_ct_struttura.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
"""Setup tests for this package."""
from iosanita.contenttypes.testing import RESTAPI_TESTING
from iosanita.contenttypes.testing import RESTAPI_TESTING, INTEGRATION_TESTING
from plone import api
from plone.app.testing import setRoles
from plone.app.testing import SITE_OWNER_NAME
Expand Down Expand Up @@ -225,3 +225,22 @@ def test_struttura_fields_ulteriori_informazioni_fieldset(self):
resp["fieldsets"][10]["fields"],
["ulteriori_informazioni"],
)


class TestStruttura(unittest.TestCase):
""""""

layer = 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"])

def test_struttura_default_children(self):
struttura = api.content.create(
container=self.portal, type="Struttura", title="xxx"
)

self.assertEqual(struttura.keys(), ["documenti", "multimedia"])
21 changes: 20 additions & 1 deletion src/iosanita/contenttypes/tests/test_ct_uo.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
"""Setup tests for this package."""
from iosanita.contenttypes.testing import RESTAPI_TESTING
from iosanita.contenttypes.testing import RESTAPI_TESTING, INTEGRATION_TESTING
from plone import api
from plone.app.testing import setRoles
from plone.app.testing import SITE_OWNER_NAME
Expand Down Expand Up @@ -197,3 +197,22 @@ def test_uo_fields_ulteriori_informazioni_fieldset(self):
"""
resp = self.api_session.get("@types/UnitaOrganizzativa").json()
self.assertEqual(resp["fieldsets"][8]["fields"], ["ulteriori_informazioni"])


class TestUO(unittest.TestCase):
""""""

layer = 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"])

def test_uo_default_children(self):
uo = api.content.create(
container=self.portal, type="UnitaOrganizzativa", title="xxx"
)

self.assertEqual(uo.keys(), ["allegati"])

0 comments on commit 3cfb60f

Please sign in to comment.