def test_set_allowed_actions_rejects_if_CANCEL_is_missing(self): actions = adhoc_xso.Actions() with self.assertRaisesRegex(ValueError, r"CANCEL must always be allowed"): actions.allowed_actions = { adhoc_xso.ActionType.EXECUTE, }
def test_set_allowed_actions(self): actions = adhoc_xso.Actions() actions.prev_is_allowed = True actions.next_is_allowed = True actions.complete_is_allowed = True actions.allowed_actions = { adhoc_xso.ActionType.EXECUTE, adhoc_xso.ActionType.CANCEL, } self.assertFalse(actions.prev_is_allowed) self.assertFalse(actions.next_is_allowed) self.assertFalse(actions.complete_is_allowed) actions.allowed_actions = { adhoc_xso.ActionType.EXECUTE, adhoc_xso.ActionType.CANCEL, adhoc_xso.ActionType.NEXT, } self.assertFalse(actions.prev_is_allowed) self.assertTrue(actions.next_is_allowed) self.assertFalse(actions.complete_is_allowed) actions.allowed_actions = { adhoc_xso.ActionType.EXECUTE, adhoc_xso.ActionType.CANCEL, adhoc_xso.ActionType.PREV, } self.assertTrue(actions.prev_is_allowed) self.assertFalse(actions.next_is_allowed) self.assertFalse(actions.complete_is_allowed) actions.allowed_actions = { adhoc_xso.ActionType.EXECUTE, adhoc_xso.ActionType.CANCEL, adhoc_xso.ActionType.COMPLETE, } self.assertFalse(actions.prev_is_allowed) self.assertFalse(actions.next_is_allowed) self.assertTrue(actions.complete_is_allowed) actions.allowed_actions = { adhoc_xso.ActionType.EXECUTE, adhoc_xso.ActionType.CANCEL, adhoc_xso.ActionType.NEXT, adhoc_xso.ActionType.PREV, adhoc_xso.ActionType.COMPLETE, } self.assertTrue(actions.prev_is_allowed) self.assertTrue(actions.next_is_allowed) self.assertTrue(actions.complete_is_allowed)
def test_allowed_actions(self): actions = adhoc_xso.Actions() self.assertSetEqual( actions.allowed_actions, {adhoc_xso.ActionType.EXECUTE, adhoc_xso.ActionType.CANCEL} ) actions.prev_is_allowed = True self.assertSetEqual( actions.allowed_actions, {adhoc_xso.ActionType.EXECUTE, adhoc_xso.ActionType.CANCEL, adhoc_xso.ActionType.PREV}, ) actions.prev_is_allowed = False actions.next_is_allowed = True self.assertSetEqual( actions.allowed_actions, {adhoc_xso.ActionType.EXECUTE, adhoc_xso.ActionType.CANCEL, adhoc_xso.ActionType.NEXT}, ) actions.next_is_allowed = False actions.complete_is_allowed = True self.assertSetEqual( actions.allowed_actions, {adhoc_xso.ActionType.EXECUTE, adhoc_xso.ActionType.CANCEL, adhoc_xso.ActionType.COMPLETE}, ) actions.next_is_allowed = True actions.prev_is_allowed = True self.assertSetEqual( actions.allowed_actions, {adhoc_xso.ActionType.EXECUTE, adhoc_xso.ActionType.CANCEL, adhoc_xso.ActionType.NEXT, adhoc_xso.ActionType.PREV, adhoc_xso.ActionType.COMPLETE}, ) self.assertIsInstance( actions.allowed_actions, frozenset )