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_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_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