Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
folix-01 committed Nov 20, 2023
1 parent dcb3a0c commit 2e7eba0
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 40 deletions.
6 changes: 4 additions & 2 deletions src/design/plone/ioprenoto/adapters/stringinterp.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,12 @@ def safe_call(self):
next(
iter(
getattr(
self.context.getPrenotazioniFolder(), "uffici_correlati", []
self.context.getPrenotazioniFolder(),
"uffici_correlati",
None,
)
or [None]
),
None,
),
"to_object",
None,
Expand Down
67 changes: 29 additions & 38 deletions src/design/plone/ioprenoto/tests/test_stringinterp.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
# -*- coding: utf-8 -*-
from datetime import date
from datetime import datetime
from design.plone.ioprenoto.testing import DESIGN_PLONE_IOPRENOTO_FUNCTIONAL_TESTING
import unittest
from datetime import date, datetime

import transaction
from plone import api
from plone.app.testing import setRoles
from plone.app.testing import TEST_USER_ID
from plone.app.testing import TEST_USER_ID, setRoles
from plone.registry.interfaces import IRegistry
from plone.stringinterp.interfaces import IContextWrapper
from plone.stringinterp.interfaces import IStringSubstitution
from plone.stringinterp.interfaces import IContextWrapper, IStringSubstitution
from plone.volto.interfaces import IVoltoSettings
from redturtle.prenotazioni.adapters.booker import IBooker
from z3c.relationfield.relation import RelationValue
from zope.component import getAdapter
from zope.component import getUtility
from zope.component import queryUtility
from zope.component import getAdapter, getUtility, queryUtility
from zope.intid.interfaces import IIntIds

import transaction
import unittest
from design.plone.ioprenoto.testing import DESIGN_PLONE_IOPRENOTO_FUNCTIONAL_TESTING


class TestStringinterp(unittest.TestCase):
Expand All @@ -29,13 +25,33 @@ def setUp(self):
self.portal_url = self.portal.absolute_url()
setRoles(self.portal, TEST_USER_ID, ["Manager"])

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.folder_prenotazioni = api.content.create(
container=self.portal,
type="PrenotazioniFolder",
title="Prenota foo",
description="",
daData=date.today(),
gates=["Gate A"],
uffici_correlati=[
RelationValue(
to_id=queryUtility(IIntIds).getId(self.unita_organizzativa)
)
],
)
week_table = self.folder_prenotazioni.week_table
week_table[0]["morning_start"] = "0700"
Expand Down Expand Up @@ -70,31 +86,6 @@ 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()

Expand Down Expand Up @@ -151,5 +142,5 @@ def test_unita_organizzativa_title(self):
getAdapter(
self.prenotazione, IStringSubstitution, "unita_organizzativa_title"
)(),
self.folder_prenotazioni.Title(),
self.unita_organizzativa.Title(),
)

0 comments on commit 2e7eba0

Please sign in to comment.