How to use the chaostoolkit.errors.UnknownAction function in chaostoolkit

To help you get started, we’ve selected a few chaostoolkit 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 chaostoolkit / chaostoolkit / tests / test_plan.py View on Github external
def test_action_must_be_implemented():
    step = {
        "action": {
            "layer": "noop",
            "name": "microservice-goes-boom",
            "parameters": {
                "name": "cherrypy-webapp"
            }
        }
    }

    with pytest.raises(UnknownAction) as excinfo:
        apply_action(step, layers)

    assert "action 'microservice_goes_boom' is not implemented" in str(excinfo)
github chaostoolkit / chaostoolkit / chaostoolkit / actions.py View on Github external
def execute_action(name: str, action: Action, layer: Layer) -> Any:
    """
    Run the given action and return its result as-is. The `name` of the action
    must match a function where dashes are replaced with underscores.

    If no function can be found with such a name, raises :exc:`UnknownAction`.
    """
    if not name:
        raise ValueError("missing action name")

    name = name.replace('-', '_')
    action_func = get_action_function(name)
    if not action_func:
        raise UnknownAction(name)

    return action_func(action, layer)