From dcb3a0cc9ca84a5a735fb35cffbc038907ef33d1 Mon Sep 17 00:00:00 2001 From: Mauro Amico Date: Fri, 17 Nov 2023 11:32:03 +0100 Subject: [PATCH] add test --- ...terp_overrides.py => test_stringinterp.py} | 57 ++++++++++++++++--- 1 file changed, 48 insertions(+), 9 deletions(-) rename src/design/plone/ioprenoto/tests/{test_stringinterp_overrides.py => test_stringinterp.py} (69%) diff --git a/src/design/plone/ioprenoto/tests/test_stringinterp_overrides.py b/src/design/plone/ioprenoto/tests/test_stringinterp.py similarity index 69% rename from src/design/plone/ioprenoto/tests/test_stringinterp_overrides.py rename to src/design/plone/ioprenoto/tests/test_stringinterp.py index ea2248c..8e28b88 100644 --- a/src/design/plone/ioprenoto/tests/test_stringinterp_overrides.py +++ b/src/design/plone/ioprenoto/tests/test_stringinterp.py @@ -1,20 +1,26 @@ # -*- coding: utf-8 -*- -import unittest -from datetime import date, datetime - -import transaction +from datetime import date +from datetime import datetime +from design.plone.ioprenoto.testing import DESIGN_PLONE_IOPRENOTO_FUNCTIONAL_TESTING from plone import api -from plone.app.testing import TEST_USER_ID, setRoles +from plone.app.testing import setRoles +from plone.app.testing import TEST_USER_ID from plone.registry.interfaces import IRegistry -from plone.stringinterp.interfaces import IContextWrapper, IStringSubstitution +from plone.stringinterp.interfaces import IContextWrapper +from plone.stringinterp.interfaces import IStringSubstitution from plone.volto.interfaces import IVoltoSettings from redturtle.prenotazioni.adapters.booker import IBooker -from zope.component import getAdapter, getUtility +from z3c.relationfield.relation import RelationValue +from zope.component import getAdapter +from zope.component import getUtility +from zope.component import queryUtility +from zope.intid.interfaces import IIntIds -from design.plone.ioprenoto.testing import DESIGN_PLONE_IOPRENOTO_FUNCTIONAL_TESTING +import transaction +import unittest -class TestStringinterpOverrides(unittest.TestCase): +class TestStringinterp(unittest.TestCase): layer = DESIGN_PLONE_IOPRENOTO_FUNCTIONAL_TESTING def setUp(self): @@ -64,6 +70,31 @@ def setUp(self): "title": "foo", } ) + self.unita_organizzativa = api.content.create( + container=self.portal, + type="UnitaOrganizzativa", + title="UO", + ) + self.servizio = api.content.create( + container=self.portal, + type="Servizio", + title="Servizio", + ufficio_responsabile=[ + RelationValue( + to_id=queryUtility(IIntIds).getId(self.unita_organizzativa) + ) + ], + ) + self.prenotazioni_folder = api.content.create( + container=self.portal, + type="PrenotazioniFolder", + title="Prenotazioni Folder", + uffici_correlati=[ + RelationValue( + to_id=queryUtility(IIntIds).getId(self.unita_organizzativa) + ) + ], + ) transaction.commit() @@ -114,3 +145,11 @@ def test_booking_print_url_override_with_custom_frontend_domain( )(), f"http://foo.bar/prenotazione-appuntamenti-uffici?booking_id={self.prenotazione.UID()}", ) + + def test_unita_organizzativa_title(self): + self.assertEqual( + getAdapter( + self.prenotazione, IStringSubstitution, "unita_organizzativa_title" + )(), + self.folder_prenotazioni.Title(), + )