Skip to content

Commit

Permalink
Refactor validation contract tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Emerson Delatorre committed Feb 13, 2024
1 parent 79c8f19 commit 77f351b
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions tests/validations/test_string_validation_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def test_should_be_valid_when_is_lower_than_20(entityMock: SampleEntity):
contract = Contract().is_lower_than(
entityMock.first_name, 20, "first_name", "any message"
)
assert contract.is_valid()
assert contract.is_valid
assert len(contract.get_notifications()) == 0


Expand All @@ -16,7 +16,7 @@ def test_should_be_invalid_and_return_once_notification_when_not_is_lower_than_5
contract = Contract().is_lower_than(
entityMock.first_name, 5, "first_name", "any message"
)
assert contract.is_valid() is False
assert contract.is_valid is False
assert len(contract.get_notifications()) == 1


Expand All @@ -26,7 +26,7 @@ def test_should_be_valid_when_is_lower_or_equals_than_20(
contract = Contract().is_lower_or_equals_than(
entityMock.first_name, 20, "first_name", "any message"
)
assert contract.is_valid()
assert contract.is_valid
assert len(contract.get_notifications()) == 0


Expand All @@ -36,15 +36,15 @@ def test_should_be_invalid_and_return_once_notification_when_not_is_lower_or_equ
contract = Contract().is_lower_or_equals_than(
entityMock.first_name, 14, "first_name", "any message"
)
assert contract.is_valid() is False
assert contract.is_valid is False
assert len(contract.get_notifications()) == 1


def test_should_be_valid_when_is_greater_than_10(entityMock: SampleEntity):
contract = Contract().is_greater_than(
entityMock.first_name, 10, "first_name", "any message"
)
assert contract.is_valid()
assert contract.is_valid
assert len(contract.get_notifications()) == 0


Expand All @@ -54,7 +54,7 @@ def test_should_be_invalid_and_return_once_notification_when_not_is_greater_than
contract = Contract().is_greater_than(
entityMock.first_name, 15, "first_name", "any message"
)
assert contract.is_valid() is False
assert contract.is_valid is False
assert len(contract.get_notifications()) == 1


Expand All @@ -64,7 +64,7 @@ def test_should_be_valid_when_is_greater_or_equals_than_13(
contract = Contract().is_greater_or_equals_than(
entityMock.first_name, 13, "first_name", "any message"
)
assert contract.is_valid()
assert contract.is_valid
assert len(contract.get_notifications()) == 0


Expand All @@ -74,35 +74,35 @@ def test_should_be_invalid_and_return_once_notification_when_not_is_greater_or_e
contract = Contract().is_greater_or_equals_than(
entityMock.first_name, 14, "first_name", "any message"
)
assert contract.is_valid() is False
assert contract.is_valid is False
assert len(contract.get_notifications()) == 1


def test_should_be_valid_when_is_none():
contract = Contract().is_none(None, "first_name", "any message")
assert contract.is_valid()
contract = Contract().is_none(None, "first_name", "any message") # type: ignore
assert contract.is_valid
assert len(contract.get_notifications()) == 0


def test_should_be_invalid_and_return_once_notification_when_not_is_none(
entityMock: SampleEntity,
):
contract = Contract().is_none(entityMock.first_name, "first_name", "any message")
assert contract.is_valid() is False
assert contract.is_valid is False
assert len(contract.get_notifications()) == 1


def test_should_be_valid_when_is_not_none(entityMock: SampleEntity):
contract = Contract().is_not_none(
entityMock.first_name, "first_name", "any message"
)
assert contract.is_valid()
assert contract.is_valid
assert len(contract.get_notifications()) == 0


def test_should_be_invalid_and_return_once_notification_when_not_none():
contract = Contract().is_not_none(None, "first_name", "any message")
assert contract.is_valid() is False
contract = Contract().is_not_none(None, "first_name", "any message") # type: ignore
assert contract.is_valid is False
assert len(contract.get_notifications()) == 1


Expand All @@ -112,19 +112,19 @@ def test_should_be_valid_when_is_not_none_or_white_space(
contract = Contract().is_not_none_or_white_space(
entityMock.first_name, "first_name", "any message"
)
assert contract.is_valid()
assert contract.is_valid
assert len(contract.get_notifications()) == 0


def test_should_be_invalid_and_return_once_notification_when_is_none():
contract = Contract().is_not_none_or_white_space(None, "first_name", "any message")
assert contract.is_valid() is False
contract = Contract().is_not_none_or_white_space(None, "first_name", "any message") # type: ignore
assert contract.is_valid is False
assert len(contract.get_notifications()) == 1


def test_should_be_invalid_and_return_once_notification_when_white_space():
contract = Contract().is_not_none_or_white_space(" ", "first_name", "any message")
assert contract.is_valid() is False
assert contract.is_valid is False
assert len(contract.get_notifications()) == 1


Expand Down

0 comments on commit 77f351b

Please sign in to comment.