Skip to content

Commit

Permalink
Add tests for percentage validation
Browse files Browse the repository at this point in the history
  • Loading branch information
bjester committed Mar 22, 2022
1 parent 4ec40e1 commit 6a0dffd
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/test_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,23 @@ def test_completion_criteria__pages_model__valid():
)


@pytest.mark.skipif(jsonschema is None, reason="jsonschema package is unavailable")
def test_completion_criteria__pages_model__percentage__valid():
with _assert_not_raises(jsonschema.ValidationError):
_validate(
{
"model": "pages",
"threshold": "99%",
}
)
_validate(
{
"model": "pages",
"threshold": "1%",
}
)


@pytest.mark.skipif(jsonschema is None, reason="jsonschema package is unavailable")
def test_completion_criteria__pages_model__invalid():
with pytest.raises(jsonschema.ValidationError):
Expand All @@ -141,6 +158,25 @@ def test_completion_criteria__pages_model__invalid():
)


@pytest.mark.skipif(jsonschema is None, reason="jsonschema package is unavailable")
def test_completion_criteria__pages_model__percentage__invalid():
with pytest.raises(jsonschema.ValidationError):
_validate(
{
"model": "pages",
"threshold": "0%",
"learner_managed": False,
}
)
with pytest.raises(jsonschema.ValidationError):
_validate(
{
"model": "pages",
"threshold": "101%",
}
)


@pytest.mark.skipif(jsonschema is None, reason="jsonschema package is unavailable")
def test_completion_criteria__mastery_model__valid():
with _assert_not_raises(jsonschema.ValidationError):
Expand Down

0 comments on commit 6a0dffd

Please sign in to comment.