How to use the spidermon.settings.CHECK_STATE_PASSED function in spidermon

To help you get started, we’ve selected a few spidermon examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github scrapinghub / spidermon / _tests / fixtures / schemas.py View on Github external
},
            "error": {
                "type": "object",
                "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": {
github scrapinghub / spidermon / _tests / actions / test_managers.py View on Github external
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'),
        ),
github scrapinghub / spidermon / _tests / fixtures / actions.py View on Github external
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),
]
github scrapinghub / spidermon / _spidermon / rules / results.py View on Github external
def passed(self):
        return self.state == settings.CHECK_STATE_PASSED
github scrapinghub / spidermon / spidermon / managers.py View on Github external
def _check_rule(self, definition, stats):
        result = RuleCheckResult(definition=definition)
        try:
            check_result = definition.rule.run_check(stats)
            result.state = settings.CHECK_STATE_PASSED if check_result else settings.CHECK_STATE_FAILED
        except Exception, e:
            result.state = settings.CHECK_STATE_ERROR
            result.error_message = str(e)
            result.error_traceback = traceback.format_exc()
        return result
github scrapinghub / spidermon / _spidermon / rules / managers.py View on Github external
def _check_rule(self, definition, stats):
        result = RuleCheckResult(definition=definition)
        try:
            check_result = definition.rule.run_check(stats)
            result.state = settings.CHECK_STATE_PASSED if check_result else settings.CHECK_STATE_FAILED
        except Exception, e:
            result.state = settings.CHECK_STATE_ERROR
            result.error_message = str(e)
            result.error_traceback = traceback.format_exc()
        return result
github scrapinghub / spidermon / spidermon / managers.py View on Github external
    @property
    def passed(self):
        return self.state == settings.CHECK_STATE_PASSED
github scrapinghub / spidermon / spidermon / managers.py View on Github external
    @property
    def passed_actions(self):
        return self._get_actions_for_trigger(settings.CHECK_STATE_PASSED)
github scrapinghub / spidermon / _spidermon / actions / managers.py View on Github external
    @property
    def passed_actions(self):
        return self._get_actions_for_trigger(settings.CHECK_STATE_PASSED)