diff --git a/argos/schemas/config.py b/argos/schemas/config.py index 4a25f74..4d78cf1 100644 --- a/argos/schemas/config.py +++ b/argos/schemas/config.py @@ -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) diff --git a/tests/test_schemas_config.py b/tests/test_schemas_config.py index 4191af4..baff271 100644 --- a/tests/test_schemas_config.py +++ b/tests/test_schemas_config.py @@ -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")]