def test_is_null_throws_error_on_invalid_value(value: str): """ Tests that the `is_null()` method does not throw an ArgumentError when it is supplied with an invalid value. """ # Arrange validator = StringValidator(value, 'value') # Assert with pytest.raises(ArgumentNullError): # Act validator.is_null()
def test_does_not_contain_throw_error_on_invalid_value(value: str, contains: str): """ Tests that the `does_not_contain()` method throws an ArgumentError when the value contains specified value. """ # Arrange validator = StringValidator(value, 'value') # Assert with pytest.raises(ArgumentError): # Act validator.does_not_contain(contains)
def test_is_longer_or_equal_throws_error_on_shorter_length(value: str, min_length: int): """ Tests that the `is_longer_or_equal()` method throws an ArgumentError when it is supplied with a shorter length. """ # Arrange validator = StringValidator(value, 'value') # Assert with pytest.raises(ArgumentError): # Act validator.is_longer_or_equal(min_length)
def test_does_not_have_length_throws_error_on_equal_length(value: str, length: int): """ Tests that the `does_not_have_length()` method throws an ArgumentError when it is supplied with a equal length. """ # Arrange validator = StringValidator(value, 'value') # Assert with pytest.raises(ArgumentError): # Act validator.does_not_have_length(length)
def test_does_not_end_with_throws_error_on_invalid_value(value: str, ends_with: str): """ Tests that the `does_not_end_with()` method throws an ArgumentError when the value ends with the specified value. """ # Arrange validator = StringValidator(value, 'value') # Assert with pytest.raises(ArgumentError): # Act validator.does_not_end_with(ends_with)
def test_starts_with_throws_error_on_invalid_value(value: str, starts_with: str): """ Tests that the `starts_with()` method throws an ArgumentError when the value does not start with the specified value. """ # Arrange validator = StringValidator(value, 'value') # Assert with pytest.raises(ArgumentError): # Act validator.starts_with(starts_with)
def test_is_not_regex_match_throws_error_on_matching_pattern(value: str, pattern: str): """ Tests that the `is_not_regex_match()` method throws an ArgumentPatternError when the value matches the specified pattern. """ # Arrange validator = StringValidator(value, 'value') # Assert with pytest.raises(ArgumentPatternError): # Act validator.is_not_regex_match(pattern)
def test_is_not_in_set_case_insensitive_throws_error_on_matching_set(value: str, set: list): """ Tests that the `is_not_in_set_case_insensitive()` method throws an ArgumentError when its value is present in the supplied set, case insensitive. """ # Arrange validator = StringValidator(value, 'value') # Assert with pytest.raises(ArgumentError): # Act validator.is_not_in_set_case_insensitive(set)
def test_is_null_throws_error_on_whitespace_value(): """ Tests that the `is_null()` method throws an ArgumentError when it is supplied with a whitespace value. """ # Arrange value = WHITESPACE_STRING validator = StringValidator(value, 'value') # Assert with pytest.raises(ArgumentNullError): # Act validator.is_null()
def test_is_not_null_or_whitespace_throw_error_on_empty_value(): """ Tests that the `is_not_null_or_whitespace()` method throws an ArgumentError when it is supplied with a whitespace value. """ # Arrange value = EMPTY_STRING validator = StringValidator(value, 'value') # Assert with pytest.raises(ArgumentError): # Act validator.is_not_null_or_whitespace()
def test_is_not_null_or_empty_throw_error_on_null_value(): """ Tests that the `is_not_null_or_empty()` method throws an ArgumentError when it is supplied with a None (Null) value. """ # Arrange value = None validator = StringValidator(value, 'value') # Assert with pytest.raises(ArgumentError): # Act validator.is_not_null_or_empty()
def test_does_not_equal_throws_error_on_equal_value(): """ Tests that the `does_not_equal()` method throws an ArgumentError when the value is equal to the specified value. """ # Arrange value = 'Hello World!' validator = StringValidator(value, 'value') # Assert with pytest.raises(ArgumentError): # Act validator.does_not_equal(value)
def test_is_not_in_set_case_insensitive_accepts_value_not_in_set(value: str, set: list): """ Tests that the `is_not_in_set_case_insensitive()` method accepts when its value is not present in the supplied set, case insensitive. """ # Arrange validator = StringValidator(value, 'value') # Act try: validator.is_not_in_set_case_insensitive(set) # Assert except ArgumentError: pytest.fail(f'`{value}` should be in the set `{set}`, but an error occurred.')
def test_is_not_null_or_whitespace_accepts_valid_value(value: str): """ Tests that the `is_not_null_or_whitespace()` method does not throw an ArgumentError when it is supplied with a valid value. """ # Arrange validator = StringValidator(value, 'value') # Act try: validator.is_not_null_or_whitespace() # Assert except (ArgumentError, ArgumentNullError): pytest.fail(f'`{value}` should not have been None (Null) or empty, but an error occurred instead.')
def test_does_not_end_with_accepts_valid_value(value: str, ends_with: str): """ Tests that the `does_not_end_with()` method does not throw an ArgumentError when the value does not end with the specified value. """ # Arrange validator = StringValidator(value, 'value') # Act try: validator.does_not_end_with(ends_with) # Assert except ArgumentError: pytest.fail(f'`{value}` should not end with `{ends_with}`, but an error occurred.')
def test_is_null_or_empty_returns_validator_self(): """ Tests if the `is_null_or_empty()` validator method returns itself after the validation is performed, so that additional validations can be performed. """ # Arrange value = EMPTY_STRING validator = StringValidator(value, 'value') # Act validator_returned = validator.is_null_or_empty() # Assert assert validator_returned is validator
def test_does_not_contain_accepts_valid_value(value: str, contains: str): """ Tests that the `does_not_contain()` method does not throw an ArgumentError when the value does not contain specified value. """ # Arrange validator = StringValidator(value, 'value') # Act try: validator.does_not_contain(contains) # Assert except ArgumentError: pytest.fail(f'`{value}` should not contain `{contains}`, but an error occurred.')
def test_is_not_regex_match_accepts_not_matching_pattern(value: str, pattern: str): """ Tests that the `is_not_regex_match()` method does not throw an ArgumentPatternError when the value does not match the specified pattern. """ # Arrange validator = StringValidator(value, 'value') # Act try: validator.is_not_regex_match(pattern) # Assert except ArgumentPatternError: pytest.fail(f'`{value}` should match the pattern `{pattern}`, but an error occurred.')
def test_is_not_null_or_whitespace_returns_validator_self(): """ Tests if the `is_not_null_or_whitespace()` validator method returns itself after the validation is performed, so that additional validations can be performed. """ # Arrange value = 'test' validator = StringValidator(value, 'value') # Act validator_returned = validator.is_not_null_or_whitespace() # Assert assert validator_returned is validator
def test_is_in_set_accepts_value_in_set(value: str, set: list): """ Tests that the `is_in_set()` method does not throw an ArgumentError when its value is present in the supplied set. """ # Arrange validator = StringValidator(value, 'value') # Act try: validator.is_in_set(set) # Assert except ArgumentError: pytest.fail(f'`{value}` should be in the set `{set}`, but an error occurred.')
def test_is_shorter_than_accepts_shorter_length(value: str, max_length: int): """ Tests that the `is_shorter_than()` method does not throw an ArgumentError when it is supplied with a shorter length. """ # Arrange validator = StringValidator(value, 'value') # Act try: validator.is_shorter_than(max_length) # Assert except ArgumentError: pytest.fail(f'`{value}` should be shorter than `{max_length}`, but an error occurred.')
def test_prnt_get_value_returns_value(value): """ Tests if the parent `get_value()` method returns the value saved in the validator. """ # Arrange validator = StringValidator(value, 'value') # Act actual = validator.get_value() # Assert assert actual == value assert actual is value assert type(actual) == type(value)
def test_is_longer_or_equal_accepts_equal_length(value: str, min_length: int): """ Tests that the `is_longer_or_equal()` method does not throw an ArgumentError when it is supplied with a equal length. """ # Arrange validator = StringValidator(value, 'value') # Act try: validator.is_longer_or_equal(min_length) # Assert except ArgumentError: pytest.fail(f'`{value}` should be longer or equal to `{min_length}`, but an error occurred.')
def test_does_not_have_length_accepts_notequal_length(value: str, length: int): """ Tests that the `does_not_have_length()` method does not throw an ArgumentError when it is supplied with a not equal length. """ # Arrange validator = StringValidator(value, 'value') # Act try: validator.does_not_have_length(length) # Assert except ArgumentError: pytest.fail(f'`{value}` should not have the length `{length}`, but an error occurred.')
def test_equals_returns_validator_self(): """ Tests if the `equals()` validator method returns itself after the validation is performed, so that additional validations can be performed. """ # Arrange value = 'test' validator = StringValidator(value, 'value') # Act validator_returned = validator.equals(value) # Assert assert validator_returned is validator
def test_is_null_accepts_null_value(): """ Tests that the `is_null()` method does not throw an ArgumentError when it is supplied with a None (Null) value. """ # Arrange value = None validator = StringValidator(value, 'value') # Act try: validator.is_null() # Assert except ArgumentNullError: pytest.fail(f'`{value}` should have been None (Null), but an error occurred instead.')
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_shorter_than_returns_validator_self(): """ Tests if the `is_shorter_than()` validator method returns itself after the validation is performed, so that additional validations can be performed. """ # Arrange value = 'test' max_length = 10 validator = StringValidator(value, 'value') # Act validator_returned = validator.is_shorter_than(max_length) # Assert assert validator_returned is validator
def test_has_length_returns_validator_self(): """ Tests if the `has_length()` validator method returns itself after the validation is performed, so that additional validations can be performed. """ # Arrange value = 'test' length = 4 validator = StringValidator(value, 'value') # Act validator_returned = validator.has_length(length) # Assert assert validator_returned is validator
def test_is_longer_or_equal_returns_validator_self(): """ Tests if the `is_longer_or_equal()` validator method returns itself after the validation is performed, so that additional validations can be performed. """ # Arrange value = 'test' min_length = 2 validator = StringValidator(value, 'value') # Act validator_returned = validator.is_longer_or_equal(min_length) # Assert assert validator_returned is validator