Skip to content

Commit 0f93951

Browse files
committed
Simplified test
1 parent 07a2ab4 commit 0f93951

File tree

1 file changed

+16
-19
lines changed

1 file changed

+16
-19
lines changed

src/imio/pm/wsclient/tests/testVocabularies.py

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -73,20 +73,16 @@ def test_desired_meetingdates_vocabulary(self, _rest_getMeetingsAcceptingItems,
7373
def test_categories_for_user_vocabulary(self, _rest_getConfigInfos):
7474
"""Ensure that vocabularies values are the expected"""
7575

76-
def set_config():
77-
setCorrectSettingsConfig(self.portal, setConnectionParams=False, withValidation=False)
78-
ws4pmsettings = getMultiAdapter((self.portal, self.portal.REQUEST), name="ws4pmclient-settings")
79-
for i in range(len(ws4pmsettings.settings().field_mappings)):
80-
if ws4pmsettings.settings().field_mappings[i]["field_name"] == "category":
81-
del ws4pmsettings.settings().field_mappings[i]
82-
break
83-
raw_voc = vocabularies.categories_for_user_vocabulary()
84-
titles = [v.title for v in raw_voc(self.portal)]
85-
tokens = [v.token for v in raw_voc(self.portal)]
86-
return titles, tokens
87-
76+
# Set the correct settings
77+
setCorrectSettingsConfig(self.portal, setConnectionParams=False, withValidation=False)
78+
ws4pmsettings = getMultiAdapter((self.portal, self.portal.REQUEST), name="ws4pmclient-settings")
79+
for i in range(len(ws4pmsettings.settings().field_mappings)):
80+
if ws4pmsettings.settings().field_mappings[i]["field_name"] == "category":
81+
del ws4pmsettings.settings().field_mappings[i]
82+
break
8883
self.portal.REQUEST.set("meetingConfigId", u"plonegov-assembly")
8984

85+
# First test with categories
9086
_rest_getConfigInfos.return_value = [
9187
{
9288
"id": u"plonegov-assembly",
@@ -99,18 +95,19 @@ def set_config():
9995
},
10096
{
10197
"id": "finances",
102-
"title": "finances",
98+
"title": "Finances",
10399
"enabled": True,
104100
},
105101
],
106102
},
107103
{"id": u"plonemeeting-assembly", "title": u"PloneMeeting Assembly"},
108104
]
109-
titles, tokens = set_config()
110-
self.assertEqual(titles, [u"finances", u"Urbanisme"])
111-
self.assertEqual(tokens, [u"finances", u"urbanisme"])
105+
voc = vocabularies.categories_for_user_vocabulary()(self.portal)
106+
self.assertListEqual(
107+
[(v.token, v.title) for v in voc], [("finances", u"Finances"), ("urbanisme", u"Urbanisme")]
108+
)
112109

110+
# Second test without categories
113111
_rest_getConfigInfos.return_value = []
114-
titles, tokens = set_config()
115-
self.assertEqual(titles, [])
116-
self.assertEqual(tokens, [])
112+
voc = vocabularies.categories_for_user_vocabulary()(self.portal)
113+
self.assertListEqual(list(voc), [])

0 commit comments

Comments
 (0)