mirror of
https://framagit.org/framasoft/framaspace/argos.git
synced 2025-04-28 09:52:38 +02:00
Changed checks to accept ints for expected values.
(In the configuration)
This commit is contained in:
parent
0ea9ad4c6e
commit
e437f48b34
2 changed files with 12 additions and 3 deletions
|
@ -56,6 +56,8 @@ def parse_checks(value):
|
|||
if name not in available_names:
|
||||
msg = f"Check should be one of f{available_names}. ({name} given)"
|
||||
raise ValueError(msg)
|
||||
if isinstance(expected, int):
|
||||
expected = str(expected)
|
||||
return (name, expected)
|
||||
|
||||
|
||||
|
|
|
@ -18,16 +18,23 @@ def test_ssl_duration_parsing():
|
|||
|
||||
|
||||
def test_path_parsing_transforms_to_tuples():
|
||||
data = {"path": "/", "checks": [{"body-contains": "youpi"}, {"status-is": 200}]}
|
||||
data = {"path": "/", "checks": [{"body-contains": "youpi"}, {"status-is": "200"}]}
|
||||
path = WebsitePath(**data)
|
||||
assert len(path.checks) == 2
|
||||
assert path.checks == [("body-contains", "youpi"), ("status-is", 200)]
|
||||
assert path.checks == [("body-contains", "youpi"), ("status-is", "200")]
|
||||
|
||||
|
||||
def test_path_ensures_check_exists():
|
||||
with pytest.raises(ValueError):
|
||||
erroneous_data = {
|
||||
"path": "/",
|
||||
"checks": [{"non-existing-key": "youpi"}, {"status-is": 200}],
|
||||
"checks": [{"non-existing-key": "youpi"}, {"status-is": "200"}],
|
||||
}
|
||||
WebsitePath(**erroneous_data)
|
||||
|
||||
|
||||
def test_expected_accepts_and_convert_ints():
|
||||
data = {"path": "/", "checks": [{"body-contains": "youpi"}, {"status-is": 200}]}
|
||||
path = WebsitePath(**data)
|
||||
assert len(path.checks) == 2
|
||||
assert path.checks == [("body-contains", "youpi"), ("status-is", "200")]
|
||||
|
|
Loading…
Reference in a new issue