Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
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)