Skip to content

Commit

Permalink
fixed test
Browse files Browse the repository at this point in the history
  • Loading branch information
daniele-andreotti committed Apr 11, 2024
1 parent 55c6813 commit 4cb2124
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ def reply(self):
for brain in brains:
bando = brain.getObject()
found = [x for x in tipologie if x["UID"] == bando.tipologia_bando]

if not found:
tipologie.append(
{
Expand Down
15 changes: 11 additions & 4 deletions src/design/plone/policy/tests/test_bandi_search_filters_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from z3c.relationfield import RelationValue
from zope.intid.interfaces import IIntIds
from plone import api
from redturtle.bandi.vocabularies import TipologiaBandoVocabularyFactory

import unittest

Expand All @@ -33,10 +34,14 @@ def setUp(self):

setRoles(self.portal, TEST_USER_ID, ["Manager"])

voc_tipologie = TipologiaBandoVocabularyFactory(self.portal)
keys = voc_tipologie.by_value.keys()
tipologia_bando = tuple(keys)[0]

intids = getUtility(IIntIds)

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

self.uo_public_1 = api.content.create(
Expand Down Expand Up @@ -78,6 +83,7 @@ def setUp(self):
type="Bando",
title="Bando in folder",
subject=("foo", "baz"),
tipologia_bando=tipologia_bando,
ufficio_responsabile=[RelationValue(intids.getId(self.uo_public_1))],
)

Expand Down Expand Up @@ -129,10 +135,11 @@ def test_endpoint_return_list_of_subjects_based_on_permissions(self):
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()
path = "/".join(self.bando_dir.getPhysicalPath()).replace("/plone/", "/")
string_request = path + "/@bandi-search-filters"
response = self.api_session.get(string_request).json()

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

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

self.assertIn(self.uo_public_1.UID(), offices)

0 comments on commit 4cb2124

Please sign in to comment.