def test_intg_rqr_is_not_equal_throws_error_on_identical_object():
    """
    Tests the `is_not_equal_to()` requires validator method through `Condition.requires_obj()` to see if it,
	throws an ArgumentError when the object is identical to the supplied object.
    """
    # Arrange
    actual = TypeExample()
    expected = TypeExample()

    # Assert
    with pytest.raises(ArgumentError):
        # Act
        Condition.requires_obj(actual, 'actual').is_not_equal_to(expected)
Ejemplo n.º 2
0
def test_is_not_equal_throws_error_on_identical_object():
    """
    Tests that the `is_not_equal_to()` method throws an ArgumentError
    when the object is identical to the supplied object.
    """
    # Arrange
    actual = TypeExample()
    expected = TypeExample()
    validator = ObjectValidator(actual, 'actual')

    # Assert
    with pytest.raises(ArgumentError):
        # Act
        validator.is_not_equal_to(expected)
Ejemplo n.º 3
0
def test_is_equal_returns_validator_self():
    """
    Tests if the `is_equal_to()` validator method returns itself after the validation is performed,
    so that additional validations can be performed.
    """
    actual = TypeExample()
    expected = TypeExample()
    validator = ObjectValidator(actual, 'actual')

    # Act
    validator_returned = validator.is_equal_to(expected)

    # Assert
    assert validator_returned is validator
def test_intg_rqr_is_equal_to_accepts_identical_object():
    """
    Tests the `is_equal_to()` requires validator method through `Condition.requires_obj()` to see if it,
	throws an ArgumentError when the object is identical to the supplied object.
    """
    # Arrange
    actual = TypeExample()
    expected = TypeExample()

    # Act
    try:
        Condition.requires_obj(actual, 'actual').is_equal_to(expected)
    # Assert
    except ArgumentError:
        pytest.fail(f'`{actual.__class__.__name__}` should be equal to `{expected.__class__.__name__}`, but an error occurred')
Ejemplo n.º 5
0
def test_is_equal_to_accepts_identical_object():
    """
    Tests that the `is_equal_to()` method does not throw an ArgumentError
    when the object is identical to the supplied object.
    """
    # Arrange
    actual = TypeExample()
    expected = TypeExample()
    validator = ObjectValidator(actual, 'actual')

    # Act
    try:
        validator.is_equal_to(expected)
    # Assert
    except ArgumentError:
        pytest.fail(f'`{actual.__class__.__name__}` should be equal to `{expected.__class__.__name__}`, but an error occurred')
def test_intg_rqr_is_not_of_type_name_throws_error_on_no_supplied_initialized_object():
    """
    Tests the `is_not_of_type_name()` requires validator method through `Condition.requires_obj()` to see if it,
	throws a TypeError when it is supplied with a type that is not initialized.
    """
    # Arrange
    obj = TypeExample()

    # Assert
    with pytest.raises(TypeError):
        # Act
        Condition.requires_obj(obj, 'obj').is_not_of_type_name(TypeExample2)
Ejemplo n.º 7
0
def test_is_null_throws_error_on_not_null_value():
    """
    Tests that the `is_null()` method throws an ArgumentNullError
    when it is supplied with a type that is not None (Null).
    """
    # Arrange
    type = TypeExample()
    validator = ObjectValidator(type, 'type')

    # Assert
    with pytest.raises(ArgumentNullError):
        # Act
        validator.is_null()
Ejemplo n.º 8
0
def test_is_not_of_type_throws_error_on_equivalent_type():
    """
    Tests that the `is_not_of_type()` method throws an ArgumentError
    when it is supplied with a type that is the same as the specified class type.
    """
    # Arrange
    obj = TypeExample()
    validator = ObjectValidator(obj, 'obj')

    # Assert
    with pytest.raises(ArgumentError):
        # Act
        validator.is_not_of_type(TypeExample)
Ejemplo n.º 9
0
def test_is_not_of_type_name_throws_error_on_no_supplied_initialized_object():
    """
    Tests that the `is_not_of_type_name()` method throws a TypeError
    when it is supplied with a type that is not initialized.
    """
    # Arrange
    obj = TypeExample()
    validator = ObjectValidator(obj, 'obj')

    # Assert
    with pytest.raises(TypeError):
        # Act
        validator.is_not_of_type_name(TypeExample2)
def test_intg_rqr_is_null_throws_error_on_not_null_value():
    """
    Tests the `is_null()` requires validator method through `Condition.requires_obj()` to see if it,
    throws an ArgumentNullError when it is supplied with a type that is not
    None (Null).
    """
    # Arrange
    type = TypeExample()

    # Assert
    with pytest.raises(ArgumentNullError):
        # Act
        Condition.requires_obj(type, 'type').is_null()
def test_intg_ensr_is_of_type_throws_error_on_different_type():
    """
    Tests the `is_of_type()` ensures validator method through `Condition.ensures_obj()` to see if it,
    throws an ArgumentError when it is supplied with a type that is different to
    the specified type.
    """
    # Arrange
    obj = TypeExample()

    # Assert
    with pytest.raises(ArgumentError):
        # Act
        Condition.ensures_obj(obj, 'obj').is_of_type(TypeExample2)
def test_intg_rqr_is_not_of_type_throws_error_on_equivalent_type():
    """
    Tests the `is_not_of_type()` requires validator method through `Condition.requires_obj()` to see if it,
    throws an ArgumentError when it is supplied with a type that is the same as the
    specified class type.
    """
    # Arrange
    obj = TypeExample()

    # Assert
    with pytest.raises(ArgumentError):
        # Act
        Condition.requires_obj(obj, 'obj').is_not_of_type(TypeExample)
def test_intg_ensr_is_of_type_accepts_equivalent_multi_types():
    """
    Tests the `is_of_type()` ensures validator method does not throw an ArgumentError
    when it is supplied with multiple types that one or more of, are equivalent to the specified type.
    """
    # Arrange
    obj = TypeExample()

    # Act
    try:
        Condition.ensures_obj(obj, 'obj').is_of_type(TypeExample, TypeExample2)
    # Assert
    except ArgumentError:
        pytest.fail(f'Type `{obj.__class__.__name__}` should match type `{TypeExample.__name__}`, but an error occurred.')
Ejemplo n.º 14
0
def test_is_not_of_type_returns_validator_self():
    """
    Tests if the `is_not_of_type()` validator method returns itself after the validation is performed,
    so that additional validations can be performed.
    """
    # Arrange
    obj = TypeExample()
    validator = ObjectValidator(obj, 'obj')

    # Act
    validator_returned = validator.is_not_of_type(TypeExample2)

    # Assert
    assert validator_returned is validator
def test_intg_rqr_is_not_of_type_accepts_different_multi_types():
    """
    Tests the `is_not_of_type()` requires validator method does not throw an ArgumentError
    when it is supplied with multiple types that are all different from the specified class type.
    """
    # Arrange
    obj = TypeExample()

    # Act
    try:
        Condition.requires_obj(obj, 'obj').is_not_of_type(TypeExample2, TypeExample3)
    # Assert
    except ArgumentError:
        pytest.fail(f'Type `{obj.__class__.__name__}` should match type `{TypeExample.__name__}`, but an error occurred.')
Ejemplo n.º 16
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
def test_intg_rqr_is_not_null_accepts_not_null_value():
    """
    Tests the `is_not_null()` requires validator method through `Condition.requires_obj()` to see if it,
    throws an ArgumentNullError when it is supplied with a type that is not None
    (Null).
    """
    # Arrange
    type = TypeExample()

    # Act
    try:
        Condition.requires_obj(type, 'type').is_not_null()
    # Assert
    except ArgumentNullError:
        pytest.fail(f'The object should have been None (Null), but an error occurred.')
def test_intg_rqr_is_not_of_type_accepts_different_type():
    """
    Tests the `is_not_of_type()` requires validator method through `Condition.requires_obj()` to see if it,
    throws an ArgumentError when it is supplied with a type that is different to the
    specified class type.
    """
    # Arrange
    obj = TypeExample()

    # Act
    try:
        Condition.requires_obj(obj, 'obj').is_not_of_type(TypeExample2)
    # Assert
    except ArgumentError:
        pytest.fail(f'Type `{obj.__class__.__name__}` should match type `{TypeExample.__name__}`, but an error occurred.')
Ejemplo n.º 19
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.º 20
0
def test_is_not_of_type_accepts_different_type():
    """
    Tests that the `is_not_of_type()` method does not throw an ArgumentError
    when it is supplied with a type that is different to the specified class type.
    """
    # Arrange
    obj = TypeExample()
    validator = ObjectValidator(obj, 'obj')

    # Act
    try:
        validator.is_not_of_type(TypeExample2)
    # Assert
    except ArgumentError:
        pytest.fail(f'Type `{obj.__class__.__name__}` should match type `{TypeExample.__name__}`, but an error occurred.')