Skip to content

Commit

Permalink
added unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Nargis Sultani committed Sep 12, 2023
1 parent 110720b commit da950b6
Showing 1 changed file with 43 additions and 20 deletions.
63 changes: 43 additions & 20 deletions src/tests/test_check_functions.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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

0 comments on commit da950b6

Please sign in to comment.