Skip to content

Commit

Permalink
Fix tests again and again and again
Browse files Browse the repository at this point in the history
  • Loading branch information
gbastien committed Jan 30, 2025
1 parent 8bb39c5 commit ac72bb7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
12 changes: 7 additions & 5 deletions src/Products/PloneMeeting/MeetingConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -4784,8 +4784,7 @@ def _check_wf_used_in_config(self,
# manage values like MeetingItem.proposed
crossed_value = crossed_value.split(".")[-1]
if crossed_states:
state_or_transition_title = \
wf.states[crossed_value].title
state_or_transition_title = wf.states[crossed_value].title
else:
# manage values like MeetingItem.propose
state_or_transition_title = \
Expand All @@ -4804,7 +4803,7 @@ def _check_wf_used_in_config(self,
context=self.REQUEST)},
context=self.REQUEST)
# special check for MeetingConfig.meetingConfigsToCloneTo, current removed
# transition could used in another cfg
# transition could be used in another cfg
cfg_id = self.getId()
tool = api.portal.get_tool('portal_plonemeeting')
for other_cfg in tool.objectValues('MeetingConfig'):
Expand All @@ -4819,12 +4818,14 @@ def _check_wf_used_in_config(self,
v['trigger_workflow_transitions_until'].split('.')[1]
in removed_or_disabled_transitions]
if values:
wf = other_cfg.getItemWorkflow(True)
transition_title = wf.transitions[values[0]].title
return translate(
'state_or_transition_can_not_be_removed_in_use_other_config',
domain='PloneMeeting',
mapping={
'transition': translate(
values[0],
transition_title,
domain="plone",
context=self.REQUEST),
'parameter_label': translate(
Expand Down Expand Up @@ -5191,9 +5192,10 @@ def validate_itemWFValidationLevels(self, values):
portal_type=self.getItemTypeName(), review_state=item_contained_states)
if brains:
aBrain = brains[0]
item_state_title = item_states[aBrain.review_state].title
return translate('item_wf_val_states_can_not_be_removed_in_use',
domain='PloneMeeting',
mapping={'item_state': translate(aBrain.review_state,
mapping={'item_state': translate(item_state_title,
domain="plone",
context=self.REQUEST),
'item_url': aBrain.getURL()},
Expand Down
11 changes: 5 additions & 6 deletions src/Products/PloneMeeting/tests/testMeetingConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -2072,15 +2072,14 @@ def test_pm_Validate_itemWFValidationLevels_removed_depending_used_state_item(se
self._disableItemValidationLevel(cfg, level=proposed_state)
values_disabled_proposed = deepcopy(cfg.getItemWFValidationLevels())
self._enableItemValidationLevel(cfg, level=proposed_state)
proposed_state = cfg.getItemWorkflow(True).states[proposed_state]
proposed_state = cfg.getItemWorkflow(True).states['%s_waiting_advices' % proposed_state]
translated_proposed_state = translate(
safe_unicode(proposed_state.title), domain="plone")
safe_unicode(proposed_state.title), domain="plone", context=self.request)
level_removed_error = \
translate(
'item_wf_val_states_can_not_be_removed_in_use',
domain='PloneMeeting',
mapping={u'item_state': "Waiting advices ({0})".format(
translated_proposed_state.lower()),
mapping={'item_state': translated_proposed_state,
'item_url': item.absolute_url()},
context=self.request)
self.assertEqual(cfg.validate_itemWFValidationLevels(values_disabled_proposed),
Expand Down Expand Up @@ -2142,7 +2141,7 @@ def test_pm_Validate_itemWFValidationLevels_removed_used_state_in_config(self):
cfg2 = self.meetingConfig2
cfg_id = cfg.getId()
tr = get_leading_transitions(
cfg.getItemWorkflow(True), self._stateMappingFor('proposed'),
cfg2.getItemWorkflow(True), self._stateMappingFor('proposed'),
not_starting_with="back")[0]
error_msg = translate(
'state_or_transition_can_not_be_removed_in_use_other_config',
Expand All @@ -2162,7 +2161,7 @@ def test_pm_Validate_itemWFValidationLevels_removed_used_state_in_config(self):
({'meeting_config': '%s' % cfg_id,
'trigger_workflow_transitions_until': '%s.%s' % (cfg_id, tr.id)},))
self.assertEqual(
cfg.validate_itemWFValidationLevels(values_disabled_proposed), error_msg)
cfg.validate_itemWFValidationLevels(values_disabled_proposed), error_msg)
# ok if transition not used
cfg2.setMeetingConfigsToCloneTo(
({'meeting_config': '%s' % cfg_id,
Expand Down

0 comments on commit ac72bb7

Please sign in to comment.