def test_is_negative_throws_error_on_positive_number(value: number): """ Tests that the `is_negative()` method does not throw an ArgumentOutOfRangeError when the value is a positive number. """ # Arrange validator = NumberValidator(value, 'value') # Assert with pytest.raises(ArgumentOutOfRangeError): # Act validator.is_negative()
def test_is_in_range_returns_validator_self(): """ Tests if the `is_in_range()` validator method returns itself after the validation is performed, so that additional validations can be performed. """ # Arrange validator = NumberValidator(5, 'value') # Act validator_returned = validator.is_in_range(1, 10) # Assert assert validator_returned is validator
def test_is_not_equal_returns_validator_self(): """ Tests if the `is_not_equal()` validator method returns itself after the validation is performed, so that additional validations can be performed. """ # Arrange validator = NumberValidator(5, "value") # Act validator_returned = validator.is_not_equal_to(10) # Assert assert validator_returned is validator
def test_is_greater_than_returns_validator_self(): """ Tests if the `is_greater_than()` validator method returns itself after the validation is performed, so that additional validations can be performed. """ # Arrange validator = NumberValidator(10, "value") # Act validator_returned = validator.is_greater_than(5) # Assert assert validator_returned is validator
def test_is_not_equal_to_throws_error_on_invalid_value(value: number, not_equal_to: number): """ Tests that the `is_not_equal()` method throws an ArgumentOutOfRangeError when it is supplied with a value that is equal to the not equal value. """ # Arrange validator = NumberValidator(value, "value") # Assert with pytest.raises(ArgumentOutOfRangeError): # Act validator.is_not_equal_to(not_equal_to)
def test_is_less_or_equal_throws_error_on_greater_than_value( value: number, max_value: number): """ Tests that the `is_less_or_equal()` method throws an ArgumentOutOfRangeError when it is supplied with a value that is greater than the maximum value. """ # Arrange validator = NumberValidator(value, "value") # Assert with pytest.raises(ArgumentOutOfRangeError): # Act validator.is_less_or_equal(max_value)
def test_is_negative_accepts_negative_number(value: number): """ Tests that the `is_negative()` method does not throw an ArgumentOutOfRangeError when the value is a negative number. """ # Arrange validator = NumberValidator(value, 'value') # Act try: validator.is_negative() # Assert except ArgumentOutOfRangeError: pytest.fail()
def test_is_in_range_throws_error_on_invalid_range(value: number, min_value: number, max_value: number): """ Tests that the `is_in_range()` method throws an ArgumentOutOfRangeError when it is supplied with a value not in the supplied range. """ # Arrange validator = NumberValidator(value, 'value') # Assert with pytest.raises(ArgumentOutOfRangeError): # Act validator.is_in_range(min_value, max_value)
def test_is_not_equal_to_accepts_valid_value(value: number, equal_to: number): """ Tests that the `is_not_equal()` method does not throw an ArgumentOutOfRangeError when it is supplied with a value that is not equal to the not equal value. """ # Arrange validator = NumberValidator(value, "value") # Act try: validator.is_not_equal_to(equal_to) # Assert except ArgumentOutOfRangeError: pytest.fail()
def test_prnt_get_value_returns_value(value): """ Tests if the parent `get_value()` method returns the value saved in the validator. """ # Arrange validator = NumberValidator(value, 'value') # Act actual = validator.get_value() # Assert assert actual == value assert actual is value assert type(actual) == type(value)
def test_is_less_or_equal_accepts_equal_value(value: number, max_value: number): """ Tests that the `is_less_or_equal()` method does not throw an ArgumentOutOfRangeError when it is supplied with a value that is equal to the maximum value. """ # Arrange validator = NumberValidator(value, "value") # Act try: validator.is_less_or_equal(max_value) # Assert except ArgumentOutOfRangeError: pytest.fail()
def test_is_less_or_equal_accepts_less_than_value(value: number, max_value: number): """ Tests that the `is_less_or_equal()` method does not throw an ArgumentOutOfRangeError when it is supplied with a value that is less than the maximum value. """ # Arrange validator = NumberValidator(value, "value") # Act try: validator.is_less_or_equal(max_value) # Assert except ArgumentOutOfRangeError: pytest.fail( f'`{value}` should be less than or equal to `{max_value}`, but instead an error occurred.' )
def test_is_in_range_accepts_valid_range(value: number, min_value: number, max_value: number): """ Tests that the `is_in_range()` validator method does not throw an ArgumentOutOfRangeError when it is suppied with a value that is within the supplied range. """ # Arrange validator = NumberValidator(value, 'value') # Act try: validator.is_in_range(min_value, max_value) # Assert except ArgumentOutOfRangeError: pytest.fail( f'`{value}` should have been accepted in the range `{min_value}-{max_value}`, but instead an error occurred.' )
def test_is_greater_than_accepts_greater_than_value(value: number, min_value: number): """ Tests that the `is_greater_than()` method does not throw an ArgumentOutOfRangeError when it is supplied with a value that is greater than the minimum value. """ # Arrange validator = NumberValidator(value, "value") # Act try: validator.is_greater_than(min_value) # Assert except ArgumentOutOfRangeError: pytest.fail( f'`{value}` should be greater than `{min_value}`, but instead an error occurred.' )