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_close_probe_must_be_implemented():
step = {
"probes": {
"close": {
"layer": "noop",
"name": "microservice-should-be-happy"
}
}
}
with pytest.raises(UnknownProbe) as excinfo:
apply_close_probe(step, layers)
assert "probe 'microservice_should_be_happy' is not implemented" in\
str(excinfo)
def test_steady_probe_must_be_implemented():
step = {
"probes": {
"steady": {
"layer": "noop",
"name": "microservice-should-be-happy"
}
}
}
with pytest.raises(UnknownProbe) as excinfo:
apply_steady_probe(step, layers)
assert "probe 'microservice_should_be_happy' is not implemented" in\
str(excinfo)
def apply_probe(name: str, probe: Probe, layer: Layer) -> Any:
"""
Apply the given probe and return its result. The name of the probe
matches a function in this module by replacing dashes with underscores.
If no function matches, raises :exc:`UnknownProbe`.
"""
if not name:
raise ValueError("missing probe name")
name = name.replace('-', '_')
probe_func = get_probe_function(name)
if not probe_func:
raise UnknownProbe(name)
return probe_func(probe, layer)