From da7f342f06fb06d7a26d37bcfccc345aafdb4bdd Mon Sep 17 00:00:00 2001 From: insolor Date: Mon, 2 Oct 2023 13:45:36 +0300 Subject: [PATCH] Add tests for validation_models --- tests/test_validation_models.py | 47 +++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 tests/test_validation_models.py diff --git a/tests/test_validation_models.py b/tests/test_validation_models.py new file mode 100644 index 0000000..ff55ad5 --- /dev/null +++ b/tests/test_validation_models.py @@ -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