How to use the spidermon.exceptions.InvalidActionDefinition 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 / actions / test_managers.py View on Github external
def test_errors():
    with pytest.raises(InvalidActionDefinition):
        ActionsManager([()])

    with pytest.raises(InvalidActionDefinition):
        ActionsManager([None])

    with pytest.raises(InvalidActionDefinition):
        ActionsManager([10])

    with pytest.raises(InvalidState):
        ActionsManager([('rule', Action(), 'WRONG STATE')])

    with pytest.raises(InvalidActionDefinition):
        ActionsManager([('rule', Action(), settings.LEVEL_NORMAL, None)])
github scrapinghub / spidermon / _tests / actions / test_managers.py View on Github external
def test_errors():
    with pytest.raises(InvalidActionDefinition):
        ActionsManager([()])

    with pytest.raises(InvalidActionDefinition):
        ActionsManager([None])

    with pytest.raises(InvalidActionDefinition):
        ActionsManager([10])

    with pytest.raises(InvalidState):
        ActionsManager([('rule', Action(), 'WRONG STATE')])

    with pytest.raises(InvalidActionDefinition):
        ActionsManager([('rule', Action(), settings.LEVEL_NORMAL, None)])
github scrapinghub / spidermon / spidermon / managers.py View on Github external
def _get_action(self, action):
        if not isinstance(action, Action):
            raise InvalidActionDefinition('Wrong action, actions must subclass Action')
        return action
github scrapinghub / spidermon / _spidermon / actions / managers.py View on Github external
def _add_action_from_tuple(self, tuple_definition):
        trigger = None
        if len(tuple_definition) == 2:
            name, action = tuple_definition
        elif len(tuple_definition) == 3:
            name, action, trigger = tuple_definition
        else:
            raise InvalidActionDefinition('Wrong Action tuple definition, you should '
                                          'either use (name, action) or '
                                          '(name, action, state)')
        self.add_action(action=action, name=name, trigger=trigger)
github scrapinghub / spidermon / spidermon / managers.py View on Github external
def _add_action_from_tuple(self, tuple_definition):
        state = None
        if len(tuple_definition) == 2:
            name, action = tuple_definition
        elif len(tuple_definition) == 3:
            name, action, state = tuple_definition
        else:
            raise InvalidActionDefinition('Wrong Action tuple definition, you should '
                                          'either use (name, action) or '
                                          '(name, action, state)')
        self.add_action(action=action, name=name, state=state)
github scrapinghub / spidermon / _spidermon / actions / definitions.py View on Github external
def _get_action(self, action):
        if not isinstance(action, Action):
            raise InvalidActionDefinition('Wrong action, actions must subclass Action')
        return action