From cbc5752de1f67c5225a2e897bcf8b4c4f4cede98 Mon Sep 17 00:00:00 2001 From: Cordell Blakkan Date: Thu, 25 Apr 2024 11:17:40 -0400 Subject: [PATCH] Add semver functional test --- yamale/tests/fixtures/semver_bad.yaml | 2 ++ yamale/tests/fixtures/semver_good.yaml | 4 ++++ yamale/tests/fixtures/semver_schema.yaml | 1 + yamale/tests/test_functional.py | 17 ++++++++++------- 4 files changed, 17 insertions(+), 7 deletions(-) create mode 100644 yamale/tests/fixtures/semver_bad.yaml create mode 100644 yamale/tests/fixtures/semver_good.yaml create mode 100644 yamale/tests/fixtures/semver_schema.yaml diff --git a/yamale/tests/fixtures/semver_bad.yaml b/yamale/tests/fixtures/semver_bad.yaml new file mode 100644 index 0000000..83e6199 --- /dev/null +++ b/yamale/tests/fixtures/semver_bad.yaml @@ -0,0 +1,2 @@ +versions: + - 1.0 diff --git a/yamale/tests/fixtures/semver_good.yaml b/yamale/tests/fixtures/semver_good.yaml new file mode 100644 index 0000000..c8b14b8 --- /dev/null +++ b/yamale/tests/fixtures/semver_good.yaml @@ -0,0 +1,4 @@ +versions: + - 1.0.0 + - 1.2.3-beta + - 99999999999999999999999.999999999999999999.99999999999999999 diff --git a/yamale/tests/fixtures/semver_schema.yaml b/yamale/tests/fixtures/semver_schema.yaml new file mode 100644 index 0000000..c58bc11 --- /dev/null +++ b/yamale/tests/fixtures/semver_schema.yaml @@ -0,0 +1 @@ +versions: list(semver()) diff --git a/yamale/tests/test_functional.py b/yamale/tests/test_functional.py index c78c8ad..805b1db 100644 --- a/yamale/tests/test_functional.py +++ b/yamale/tests/test_functional.py @@ -38,6 +38,9 @@ top_level_map = {"schema": "top_level_map.yaml", "good": "top_level_map_good.yaml"} +semver = {"schema": "semver_schema.yaml", "good": "semver_good.yaml", "bad": "semver_bad.yaml"} + + include_validator = { "schema": "include_validator.yaml", "good": "include_validator_good.yaml", @@ -113,6 +116,7 @@ nested_issue_54, map_key_constraint, numeric_bool_coercion, + semver, subset, subset_empty, ] @@ -125,11 +129,6 @@ d[key] = yamale.make_data(get_fixture(d[key])) -def test_tests(): - """Make sure the test runner is working.""" - assert 1 + 1 == 2 - - def test_flat_make_schema(): assert isinstance(types["schema"]._schema["string"], val.String) @@ -143,9 +142,9 @@ def test_nested_schema(): @pytest.mark.parametrize("data_map", test_data) def test_good(data_map): - for k, v in data_map.items(): + for k, good_data in data_map.items(): if k.startswith("good"): - yamale.validate(data_map["schema"], data_map[k]) + yamale.validate(data_map["schema"], good_data) def test_bad_validate(): @@ -202,6 +201,10 @@ def test_undefined_include(): assert count_exception_lines(any_undefined["schema"], any_undefined["bad"]) == 1 +def test_bad_semver(): + assert count_exception_lines(semver["schema"], semver["bad"]) == 1 + + def test_bad_regexes(): assert count_exception_lines(regexes["schema"], regexes["bad"]) == 4