Skip to content

Commit

Permalink
Add semver functional test
Browse files Browse the repository at this point in the history
  • Loading branch information
cblakkan committed Apr 25, 2024
1 parent 113e5b0 commit cbc5752
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
2 changes: 2 additions & 0 deletions yamale/tests/fixtures/semver_bad.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
versions:
- 1.0
4 changes: 4 additions & 0 deletions yamale/tests/fixtures/semver_good.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
versions:
- 1.0.0
- 1.2.3-beta
- 99999999999999999999999.999999999999999999.99999999999999999
1 change: 1 addition & 0 deletions yamale/tests/fixtures/semver_schema.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
versions: list(semver())
17 changes: 10 additions & 7 deletions yamale/tests/test_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -113,6 +116,7 @@
nested_issue_54,
map_key_constraint,
numeric_bool_coercion,
semver,
subset,
subset_empty,
]
Expand All @@ -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)

Expand All @@ -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():
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit cbc5752

Please sign in to comment.