Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"properties": {
"message": {"type": "string"},
"traceback": {"type": "string"},
},
"required": ["message", "traceback"],
},
},
"required": ["state", "rule"],
}
}
CHECK_RESULTS_PASS_SCHEMA = copy.deepcopy(CHECK_RESULTS_SCHEMA)
CHECK_RESULTS_PASS_SCHEMA['items']['properties']['state']['enum'] = [settings.CHECK_STATE_PASSED]
CHECK_RESULTS_FAIL_SCHEMA = copy.deepcopy(CHECK_RESULTS_SCHEMA)
CHECK_RESULTS_FAIL_SCHEMA['items']['properties']['state']['enum'] = [settings.CHECK_STATE_FAILED]
CHECK_RESULTS_ERROR_SCHEMA = copy.deepcopy(CHECK_RESULTS_SCHEMA)
CHECK_RESULTS_ERROR_SCHEMA['items']['properties']['state']['enum'] = [settings.CHECK_STATE_ERROR]
CHECK_RESULTS_ERROR_SCHEMA['items']['required'].append('error')
ACTION_RESULTS_SCHEMA = {
"type": "array",
"items": {
"type": "object",
"properties": {
"state": {"enum": list(settings.ACTION_STATES)},
"action": {
"type": "object",
"properties": {
"name": {"type": "string"},
ACTIONS = [
DummyAction(),
DummyAction(),
DummyAction(),
]
ACTIONS_AS_TUPLE2 = [
('A', DummyAction()),
('B', DummyAction()),
('C', DummyAction()),
]
ACTIONS_AS_TUPLE3 = [
('Always', DummyAction(), settings.CHECK_STATE_ALWAYS),
('On Passed', DummyAction(), settings.CHECK_STATE_PASSED),
('On Failed', DummyAction(), settings.CHECK_STATE_FAILED),
('On Error', DummyAction(), settings.CHECK_STATE_ERROR),
]
def test_rules_as_tuple3():
manager = ActionsManager(ACTIONS_AS_TUPLE3)
_test_actions(
actions=manager.definitions,
values=(
# (class, trigger, name)
(DummyAction, settings.CHECK_STATE_ALWAYS, 'Always'),
(DummyAction, settings.CHECK_STATE_PASSED, 'On Passed'),
(DummyAction, settings.CHECK_STATE_FAILED, 'On Failed'),
(DummyAction, settings.CHECK_STATE_ERROR, 'On Error'),
),
@property
def failed(self):
return self.state == settings.CHECK_STATE_FAILED
def failed(self):
return self.state == settings.CHECK_STATE_FAILED
@property
def failed_actions(self):
return self._get_actions_for_trigger(settings.CHECK_STATE_FAILED)
@property
def failed_actions(self):
return self._get_actions_for_trigger(settings.CHECK_STATE_FAILED)