How to use the spidermon.settings 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 / test_levels.py View on Github external
from __future__ import absolute_import
from spidermon import settings

from .fixtures.levels import *

HIGH = settings.MONITOR.LEVEL.HIGH
NORMAL = settings.MONITOR.LEVEL.NORMAL
LOW = settings.MONITOR.LEVEL.LOW


LEVEL_TESTS = [
    # ---------------------------------------------------------------------------------------
    # suite                     monitor/methods                                expected level
    # ---------------------------------------------------------------------------------------
    # Suite No Level
    (Suites.NoLevelSuite, Monitors.NoLevelMonitor.NoLevelMethod, NORMAL),
    (Suites.NoLevelSuite, Monitors.NoLevelMonitor.HighLevelMethod, HIGH),
    (Suites.NoLevelSuite, Monitors.NoLevelMonitor.NormalLevelMethod, NORMAL),
    (Suites.NoLevelSuite, Monitors.NoLevelMonitor.LowLevelMethod, LOW),
    (Suites.NoLevelSuite, Monitors.HighLevelMonitor.NoLevelMethod, HIGH),
    (Suites.NoLevelSuite, Monitors.HighLevelMonitor.HighLevelMethod, HIGH),
    (Suites.NoLevelSuite, Monitors.HighLevelMonitor.NormalLevelMethod, NORMAL),
    (Suites.NoLevelSuite, Monitors.HighLevelMonitor.LowLevelMethod, LOW),
github scrapinghub / spidermon / _spidermon / actions / definitions.py View on Github external
def _get_trigger(self, trigger):
        if trigger and trigger not in settings.ACTION_TRIGGERS:
            raise InvalidState("Invalid state '%s'" % trigger)
        return trigger or settings.DEFAULT_CHECK_STATE
github scrapinghub / spidermon / spidermon / python / factory.py View on Github external
def _create_test_method(expression, name=None, description=None, fail_reason=None):
    def _test_method(self):
        interpreter = Interpreter()
        context = self.get_context_data()
        result = interpreter.eval(expression, context=context)
        if result is not None:
            self.assertTrue(
                bool(result),
                msg=('Expression not safisfied: "%s"' % expression)
                if not fail_reason
                else interpreter.eval(fail_reason, context=context),
            )

    test_method = _test_method
    MonitorOptions.add_or_create(test_method)
    test_method.options.name = name or settings.MONITOR.DEFAULT_NAME
    test_method.options.description = (
        description or settings.MONITOR.DEFAULT_DESCRIPTION
    )
    return test_method
github scrapinghub / spidermon / spidermon / managers.py View on Github external
def _get_level(self, level):
        if level and level not in settings.LEVELS:
            raise InvalidRuleLevel("Invalid rule severity level '%s'" % level)
        return level or settings.DEFAULT_LEVEL
github scrapinghub / spidermon / spidermon / managers.py View on Github external
def _run_action(self, definition, result):
        action_result = ActionRunResult(definition=definition)
        try:
            definition.action.run(result)
            action_result.state = settings.ACTION_STATE_PROCESSED
        except Exception, e:
            action_result.state = settings.ACTION_STATE_ERROR
            action_result.error_message = str(e)
            action_result.error_traceback = traceback.format_exc()
        return action_result
github scrapinghub / spidermon / spidermon / results / monitor.py View on Github external
def addExpectedFailure(self, test, error):
        super(MonitorResult, self).addExpectedFailure(test, error)
        self.step[test].status = settings.MONITOR.STATUS.EXPECTED_FAILURE
        self.step[test].error = self._exc_info_to_string(error, test)
github scrapinghub / spidermon / spidermon / managers.py View on Github external
    @property
    def skipped(self):
        return self.state == settings.ACTION_STATE_SKIPPED