Ejemplo n.º 1
0
def test_is_not_null_throws_error_on_null_value():
    """
    Tests that the `is_not_null()` method throws an ArgumentNullError
    when it is supplied with a type that is None (Null).
    """
    # Arrange
    type = None
    validator = ObjectValidator(type, 'type')

    # Assert
    with pytest.raises(ArgumentNullError):
        # Act
        validator.is_not_null()
Ejemplo n.º 2
0
def test_is_not_null_accepts_not_null_value():
    """
    Tests that the `is_not_null()` method does not throw an ArgumentNullError
    when it is supplied with a type that is not None (Null).
    """
    # Arrange
    type = TypeExample()
    validator = ObjectValidator(type, 'type')

    # Act
    try:
        validator.is_not_null()
    # Assert
    except ArgumentNullError:
        pytest.fail(f'The object should have been None (Null), but an error occurred.')
Ejemplo n.º 3
0
def test_is_not_null_returns_validator_self():
    """
    Tests if the `is_not_null()` validator method returns itself after the validation is performed,
    so that additional validations can be performed.
    """
    # Arrange
    type = TypeExample()
    validator = ObjectValidator(type, 'type')

    # Act
    validator_returned = validator.is_not_null()

    # Assert
    assert validator_returned is validator