Skip to content

Commit

Permalink
Add tests for validation_models
Browse files Browse the repository at this point in the history
  • Loading branch information
insolor committed Oct 2, 2023
1 parent d237f93 commit da7f342
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions tests/test_validation_models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import pytest

from df_translation_toolkit.validation.validation_models import ProblemSeverity, ValidationProblem, ValidationException


@pytest.mark.parametrize(
"test_data, expected",
[
(ProblemSeverity.ERROR, "Error"),
(ProblemSeverity.WARNING, "Warning"),
]
)
def test_problem_severity_str(test_data, expected):
assert str(test_data) == expected


@pytest.mark.parametrize(
"test_data, expected",
[
(ValidationProblem("Error message"), "Error: Error message"),
(ValidationProblem("Warning message", ProblemSeverity.WARNING), "Warning: Warning message"),
]
)
def test_validation_problem_str(test_data, expected):
assert str(test_data) == expected


@pytest.mark.parametrize(
"test_data, expected",
[
([ValidationProblem("Error")], True),
([ValidationProblem("Warning", ProblemSeverity.WARNING)], False),
]
)
def test_validation_problem_contains_errors(test_data, expected):
assert ValidationProblem.contains_errors(test_data) == expected


@pytest.mark.parametrize(
"test_data, expected",
[
([ValidationProblem("Error message")], "Error: Error message"),
([ValidationProblem("Warning message", ProblemSeverity.WARNING)], "Warning: Warning message"),
]
)
def test_validation_problem_contains_errors(test_data, expected):
assert str(ValidationException(test_data)) == expected

0 comments on commit da7f342

Please sign in to comment.