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_needs_a_name():
step = {
"action": {
"parameters": {
"name": "cherrypy-webapp"
}
}
}
with pytest.raises(InvalidPlan) as excinfo:
apply_action(step, layers)
assert "action requires a name" in str(excinfo)
def apply_steady_probe(step: Dict[str, Any], layers: Dict[str, Layer]):
"""
Apply the steady probe found in this step. If none is defined, does
nothing.
When the name of the probe is not recognized, fails the call with an
:exc:`UnknownProbe` exception.
"""
probe = get_probe_from_step(step, "steady")
if probe is None:
return
if "name" not in probe:
raise InvalidPlan("steady probe requires a probe name to apply")
if "layer" not in probe:
raise InvalidPlan("steady probe requires the target layer to be set")
if probe:
probe_name = probe.pop("name")
layer = layers.get(probe["layer"])
logger.info(" Applying steady probe '{name}'".format(name=probe_name))
apply_probe(probe_name, probe, layer)
Apply the saction found in this step. If none is defined, does
nothing.
When the name of the probe is not recognized, fails the call with an
:exc:`UnknownAction` exception.
"""
action = step.get("action")
if not action:
return
action_name = action.get("name")
if not action_name:
raise InvalidPlan("action requires a name")
if "layer" not in action:
raise InvalidPlan("action requires the target layer to be set")
pause(action, "before")
logger.info(" Executing action '{name}'".format(name=action_name))
layer = layers.get(action["layer"])
execute_action(action_name, action, layer)
pause(action, "after")
"""
Apply the steady probe found in this step. If none is defined, does
nothing.
When the name of the probe is not recognized, fails the call with an
:exc:`UnknownProbe` exception.
"""
probe = get_probe_from_step(step, "steady")
if probe is None:
return
if "name" not in probe:
raise InvalidPlan("steady probe requires a probe name to apply")
if "layer" not in probe:
raise InvalidPlan("steady probe requires the target layer to be set")
if probe:
probe_name = probe.pop("name")
layer = layers.get(probe["layer"])
logger.info(" Applying steady probe '{name}'".format(name=probe_name))
apply_probe(probe_name, probe, layer)
def apply_close_probe(step: Dict[str, Any], layers: Dict[str, Layer]):
"""
Apply the close probe found in this step. If none is defined, does
nothing.
When the name of the probe is not recognized, fails the call with an
:exc:`UnknownProbe` exception.
"""
probe = get_probe_from_step(step, "close")
if probe is None:
return
if "name" not in probe:
raise InvalidPlan("close probe requires a probe name to apply")
if "layer" not in probe:
raise InvalidPlan("close probe requires the target layer to be set")
if probe:
probe_name = probe.pop("name")
layer = layers.get(probe["layer"])
logger.info(" Applying close probe '{name}'".format(name=probe_name))
apply_probe(probe_name, probe, layer)
"""
Apply the close probe found in this step. If none is defined, does
nothing.
When the name of the probe is not recognized, fails the call with an
:exc:`UnknownProbe` exception.
"""
probe = get_probe_from_step(step, "close")
if probe is None:
return
if "name" not in probe:
raise InvalidPlan("close probe requires a probe name to apply")
if "layer" not in probe:
raise InvalidPlan("close probe requires the target layer to be set")
if probe:
probe_name = probe.pop("name")
layer = layers.get(probe["layer"])
logger.info(" Applying close probe '{name}'".format(name=probe_name))
apply_probe(probe_name, probe, layer)