diff --git a/src/tests/test_check_functions.py b/src/tests/test_check_functions.py index e40caeef..bb8d71fe 100644 --- a/src/tests/test_check_functions.py +++ b/src/tests/test_check_functions.py @@ -1,26 +1,21 @@ import pandas as pd +import pytest from validator import global_data -from validator.check_functions import ( - has_correct_length, - has_no_conditional_field_conflict, - has_valid_enum_pair, - has_valid_fieldset_pair, - has_valid_format, - has_valid_multi_field_value_count, - has_valid_value_count, - is_date, - is_greater_than, - is_greater_than_or_equal_to, - is_less_than, - is_number, - is_unique_column, - is_unique_in_field, - is_valid_code, - is_valid_enum, - meets_multi_value_field_restriction, - string_contains, -) +from validator.check_functions import (has_correct_length, + has_no_conditional_field_conflict, + has_valid_enum_pair, + has_valid_fieldset_pair, + has_valid_format, + has_valid_multi_field_value_count, + has_valid_value_count, is_date, + is_greater_than, + is_greater_than_or_equal_to, + is_less_than, is_number, + is_unique_column, is_unique_in_field, + is_valid_code, is_valid_enum, + meets_multi_value_field_restriction, + string_contains) class TestInvalidDateFormat: @@ -868,3 +863,31 @@ def test_with_incorrect_values(self): ) is False ) + + class TestSBLCheck: + import pytest + +from validator.checks import SBLCheck + + +class TestSBLCheck: + def test_no_id_check(self): + with pytest.raises(Exception) as exc: + SBLCheck(lambda: True, warning=True, name="Just a Warning") + + assert "Each check must be assigned a `name` and an `id`." in str(exc.value) + assert exc.type == ValueError + + def test_no_name_check(self): + with pytest.raises(Exception) as exc: + SBLCheck(lambda: True, id="00000", warning=True) + + assert "Each check must be assigned a `name` and an `id`." in str(exc.value) + assert exc.type == ValueError + def test_name_and_id_check(self): + raised = False + try: + SBLCheck(lambda: True, id="00000", warning=True, name="Just a Warning") + except: + raised = True + assert raised == False