Skip to content

Commit

Permalink
added test
Browse files Browse the repository at this point in the history
  • Loading branch information
daniele-andreotti committed Apr 10, 2024
1 parent b8253c5 commit 55c6813
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/design/plone/policy/tests/test_bandi_search_filters_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ def setUp(self):
setRoles(self.portal, TEST_USER_ID, ["Manager"])

intids = getUtility(IIntIds)

self.bando_dir = api.content.create(
container=self.portal type="Folder", title="Bandi test folder"
)

self.uo_public_1 = api.content.create(
container=self.portal, type="UnitaOrganizzativa", title="UO 1"
)
Expand Down Expand Up @@ -68,10 +73,19 @@ def setUp(self):
ufficio_responsabile=[RelationValue(intids.getId(self.uo_public_1))],
)

self.bando_in_folder = api.content.create(
container=self.bando_dir,
type="Bando",
title="Bando in folder",
subject=("foo", "baz"),
ufficio_responsabile=[RelationValue(intids.getId(self.uo_public_1))],
)

api.content.transition(obj=self.uo_public_1, transition="publish")
api.content.transition(obj=self.uo_public_2, transition="publish")
api.content.transition(obj=self.bando_public_1, transition="publish")
api.content.transition(obj=self.bando_public_2, transition="publish")
api.content.transition(obj=self.bando_in_folder, transition="publish")

commit()

Expand Down Expand Up @@ -113,3 +127,12 @@ def test_endpoint_return_list_of_subjects_based_on_permissions(self):
subjects = [x["UID"] for x in response["subjects"]]
self.assertEqual(len(subjects), 2)
self.assertEqual(subjects, ["bar", "foo"])

def test_endpoint_return_related_office_for_bando_by_path(self):
response = self.api_session.get("/@bandi-search-filters").json()

self.assertIn("offices", response)
offices = [x["UID"] for x in response["offices"]]

self.assertEqual(offices, ["bar", "baz", "foo"])

0 comments on commit 55c6813

Please sign in to comment.