def test_intg_rqr_is_null_throws_error_on_invalid_value(value: str):
    """
    Tests the `is_null()` through `Condition.requires_str()` to see if it,
    throws an ArgumentError when it is supplied with an invalid value.
    """
    # Assert
    with pytest.raises(ArgumentNullError):
        # Act
        Condition.requires_str(value, 'value').is_null()
def test_intg_rqr_is_negative_throws_error_on_positive_number(value: number):
    """
    Tests the `is_negative()` requires validator method does not throw an ArgumentOutOfRangeError
    when the value is a positive number.
    """
    # Assert
    with pytest.raises(ArgumentOutOfRangeError):
        # Act
        Condition.requires_num(value, 'value').is_negative()
def test_intg_rqr_is_longer_or_equal_throws_error_on_shorter_length(
        value: str, min_length: int):
    """
    Tests the `is_longer_or_equal()` through `Condition.requires_str()` to see if it,
    throws an ArgumentError when it is supplied with a shorter length.
    """
    # Assert
    with pytest.raises(ArgumentError):
        # Act
        Condition.requires_str(value, 'value').is_longer_or_equal(min_length)
def test_intg_ensr_contains_throw_error_on_invalid_value(
        value: str, contains: str):
    """
    Tests the `contains()` through `Condition.ensures_str()` to see if it,
    throws an ArgumentError when the value does not contain specified value.
    """
    # Assert
    with pytest.raises(ArgumentError):
        # Act
        Condition.ensures_str(value, 'value').contains(contains)
def test_intg_ensr_ends_with_throws_error_on_invalid_value(
        value: str, ends_with: str):
    """
    Tests the `ends_with()` through `Condition.ensures_str()` to see if it,
    throws an ArgumentError when the value does not end with the specified value.
    """
    # Assert
    with pytest.raises(ArgumentError):
        # Act
        Condition.ensures_str(value, 'value').ends_with(ends_with)
def test_intg_ensr_has_length_throws_error_on_notequal_length(
        value: str, length: int):
    """
    Tests the `has_length()` through `Condition.ensures_str()` to see if it,
    throws an ArgumentError when it is supplied with a not equal length.
    """
    # Assert
    with pytest.raises(ArgumentError):
        # Act
        Condition.ensures_str(value, 'value').has_length(length)
def test_intg_ensr_is_longer_than_throws_error_on_equal_length(
        value: str, min_length: int):
    """
    Tests the `is_longer_than()` through `Condition.ensures_str()` to see if it,
    throws an ArgumentError when it is supplied with a equal length.
    """
    # Assert
    with pytest.raises(ArgumentError):
        # Act
        Condition.ensures_str(value, 'value').is_longer_than(min_length)
def test_intg_ensr_is_null_or_whitespace_throws_error_on_invalid_value(
        value: str):
    """
    Tests the `is_not_null_or_whitespace()` through `Condition.ensures_str()` to see if it,
    throws an ArgumentError when it is supplied with an invalid value.
    """
    # Assert
    with pytest.raises(ArgumentError):
        # Act
        Condition.ensures_str(value, 'value').is_null_or_whitespace()
def test_intg_rqr_does_not_have_length_throws_error_on_equal_length(
        value: str, length: int):
    """
    Tests the `does_not_have_length()` through `Condition.requires_str()` to see if it,
    throws an ArgumentError when it is supplied with a equal length.
    """
    # Assert
    with pytest.raises(ArgumentError):
        # Act
        Condition.requires_str(value, 'value').does_not_have_length(length)
def test_intg_ensr_is_regex_match_throws_error_on_not_matching_pattern(
        value: str, pattern: str):
    """
    Tests the `is_regex_match()` through `Condition.ensures_str()` to see if it,
    throws an ArgumentError when the value does not match the specified pattern.
    """
    # Act
    with pytest.raises(ArgumentPatternError):
        # Act
        Condition.ensures_str(value, 'value').is_regex_match(pattern)
def test_intg_rqr_is_not_regex_match_throws_error_on_matching_pattern(
        value: str, pattern: str):
    """
    Tests the `is_not_regex_match()` requires validator method through `Condition.requires_str()` to see if it,
    throws an ArgumentError when the value matches the specified pattern.
    """
    # Assert
    with pytest.raises(ArgumentPatternError):
        # Act
        Condition.requires_str(value, 'value').is_not_regex_match(pattern)
def test_intg_rqr_does_not_end_with_throws_error_on_invalid_value(
        value: str, ends_with: str):
    """
    Tests the `does_not_end_with()` through `Condition.requires_str()` to see if it,
    throws an ArgumentError when the value ends with the specified value.
    """
    # Assert
    with pytest.raises(ArgumentError):
        # Act
        Condition.requires_str(value, 'value').does_not_end_with(ends_with)
def test_intg_rqr_does_not_contain_throw_error_on_invalid_value(
        value: str, contains: str):
    """
    Tests the `does_not_contain()` through `Condition.requires_str()` to see if it,
    throws an ArgumentError when the value contains specified value.
    """
    # Assert
    with pytest.raises(ArgumentError):
        # Act
        Condition.requires_str(value, 'value').does_not_contain(contains)
def test_intg_rqr_is_negative_accepts_negative_number(value: number):
    """
    Tests the `is_negative()` requires validator method does not throw an ArgumentOutOfRangeError
    when the value is a negative number.
    """
    # Act
    try:
        Condition.requires_num(value, 'value').is_negative()
    # Assert
    except ArgumentOutOfRangeError:
        pytest.fail()
def test_intg_rqr_is_not_null_or_whitespace_throw_error_on_null_value():
    """
    Tests the `is_not_null_or_whitespace()` through `Condition.requires_str()` to see if it,
    throws an ArgumentError when it is supplied with a None (Null) value.
    """
    # Arrange
    value = None

    # Assert
    with pytest.raises(ArgumentError):
        # Act
        Condition.requires_str(value, 'value').is_not_null_or_whitespace()
def test_intg_ensr_is_not_null_or_whitespace_throw_error_on_empty_value():
    """
    Tests the `is_not_null_or_whitespace()` through `Condition.ensures_str()` to see if it,
    throws an ArgumentError when it is supplied with a whitespace value.
    """
    # Arrange
    value = EMPTY_STRING

    # Assert
    with pytest.raises(ArgumentError):
        # Act
        Condition.ensures_str(value, 'value').is_not_null_or_whitespace()
def test_intg_rqr_is_null_or_empty_throws_error_on_whitespace_value():
    """
    Tests the `is_null_or_empty()` through `Condition.requires_str()` to see if it,
    throws an ArgumentError when it is supplied with a whitespace value.
    """
    # Arrange
    value = WHITESPACE_STRING

    # Assert
    with pytest.raises(ArgumentError):
        # Act
        Condition.requires_str(value, 'value').is_null_or_empty()
def test_intg_rqr_is_not_null_throws_error_on_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 None (Null).
    """
    # Arrange
    type = None

    # Assert
    with pytest.raises(ArgumentNullError):
        # Act
        Condition.requires_obj(type, 'type').is_not_null()
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)
def test_intg_rqr_is_null_throws_error_on_empty_value():
    """
    Tests the `is_null()` through `Condition.requires_str()` to see if it,
    throws an ArgumentError when it is supplied with an empty value.
    """
    # Arrange
    value = EMPTY_STRING

    # Assert
    with pytest.raises(ArgumentNullError):
        # Act
        Condition.requires_str(value, 'value').is_null()
def test_intg_rqr_is_not_of_type_name_throws_error_on_the_same_type():
    """
    Tests the `is_not_of_type_name()` 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 type instance.
    """
    # Arrange
    type_name = type('type', (object,), {})()

    # Assert
    with pytest.raises(ArgumentError):
        # Act
        Condition.requires_obj(type, 'actual').is_not_of_type_name(type_name)
Esempio n. 22
0
def test_intg_ensr_is_false_throws_argument_error_on_true():
    """
    Tests the `is_false()` ensures validator method through `Condition.ensures_bool()` to see if it,
	throws an `ArgumentError` when the supplied value is True.
    """
    # Arrange
    value = True

    # Assert
    with pytest.raises(ArgumentError):
        # Act
        Condition.ensures_bool(value, 'value').is_false()
Esempio n. 23
0
def test_intg_rqr_is_true_throws_error_on_false():
    """
    Tests the `is_true()` requires validator method through `Condition.requires_bool()` to see if it,
	throws an `ArgumentError` when the supplied value is False.
    """
    # Arrange
    value = False

    # Assert
    with pytest.raises(ArgumentError):
        # Act
        Condition.requires_bool(value, 'value').is_true()
def test_intg_rqr_contains_accepts_valid_value(value: str, contains: str):
    """
    Tests the `contains()` through `Condition.requires_str()` to see if it,
    does not throw an ArgumentError when the value does contains specified value.
    """
    # Act
    try:
        Condition.requires_str(value, 'value').contains(contains)
    # Assert
    except ArgumentError:
        pytest.fail(
            f'`{value}` should contain `{contains}`, but an error occurred.')
def test_intg_rqr_ends_with_accepts_valid_value(value: str, ends_with: str):
    """
    Tests the `ends_with()` through `Condition.requires_str()` to see if it,
    does not throw an ArgumentError when the value ends with the specified value.
    """
    # Act
    try:
        Condition.requires_str(value, 'value').ends_with(ends_with)
    # Assert
    except ArgumentError:
        pytest.fail(
            f'`{value}` should end with `{ends_with}`, but an error occurred.')
def test_intg_rqr_does_not_equal_throws_error_on_equal_value():
    """
    Tests the `equals()` requires validator method throws an ArgumentError
    when the value is not equal to the specified value.
    """
    # Arrange
    value = 'Hello World!'

    # Assert
    with pytest.raises(ArgumentError):
        # Act
        Condition.requires_str(value, 'value').does_not_equal(value)
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_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)
def test_intg_rqr_is_not_null_or_whitespace_accepts_valid_value(value: str):
    """
    Tests the `is_not_null_or_whitespace()` through `Condition.requires_str()` to see if it,
    does not throw an ArgumentError when it is supplied with a valid value.
    """
    # Assert
    try:
        Condition.requires_str(value, 'value').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_intg_rqr_has_length_accepts_equal_length(value: str, length: int):
    """
    Tests the `has_length()` through `Condition.requires_str()` to see if it,
    does not throw an ArgumentError when it is supplied with a equal length.
    """
    # Act
    try:
        Condition.requires_str(value, 'value').has_length(length)
    # Assert
    except ArgumentError:
        pytest.fail(
            f'`{value}` should have the length `{length}`, but an error occurred.'
        )