def test_is_null_or_whitespace_throws_error_on_invalid_value(value: str): """ Tests that the `is_not_null_or_whitespace()` method throws an ArgumentError when it is supplied with an invalid value. """ # Arrange validator = StringValidator(value, 'value') # Assert with pytest.raises(ArgumentError): # Act validator.is_null_or_whitespace()
def test_is_null_or_whitespace_accepts_whitespace_value(): """ Tests that the `is_not_null_or_whitespace()` method does not throw an ArgumentError when it is supplied with a whitespace value. """ # Arrange value = WHITESPACE_STRING validator = StringValidator(value, 'value') # Act try: validator.is_null_or_whitespace() # Assert except ArgumentError: pytest.fail(f'`{value}` should have been None (Null), empty or whitespace, but an error occurred instead.')
def test_is_null_or_whitespace_returns_validator_self(): """ Tests if the `is_null_or_whitespace()` validator method returns itself after the validation is performed, so that additional validations can be performed. """ # Arrange value = WHITESPACE_STRING validator = StringValidator(value, 'value') # Act validator_returned = validator.is_null_or_whitespace() # Assert assert validator_returned is validator