Exemple #1
0
def test_url_keyword_is_required(msg_assertions, MESSAGES):
    with pytest.raises(ValidationError) as err:
        external_docs_validator({})

    msg_assertions.assert_message_in_errors(
        MESSAGES['required']['required'],
        err.value.detail,
        'url',
    )
Exemple #2
0
def test_external_docs_type_validation_with_correct_type(msg_assertions):
    try:
        external_docs_validator({})
    except ValidationError as err:
        errors = err.detail
    else:
        errors = {}

    msg_assertions.assert_path_not_in_errors('type', errors)
Exemple #3
0
def test_description_keyword_is_not_required(msg_assertions):
    try:
        external_docs_validator({})
    except ValidationError as err:
        errors = err.detail
    else:
        errors = {}

    msg_assertions.assert_path_not_in_errors('description', errors)
def test_url_keyword_is_required(msg_assertions, MESSAGES):
    with pytest.raises(ValidationError) as err:
        external_docs_validator({})

    msg_assertions.assert_message_in_errors(
        MESSAGES['required']['required'],
        err.value.detail,
        'url',
    )
Exemple #5
0
def test_external_docs_type_validation(value, MESSAGES, msg_assertions):
    with pytest.raises(ValidationError) as err:
        external_docs_validator(value)

    msg_assertions.assert_message_in_errors(
        MESSAGES['type']['invalid'],
        err.value.detail,
        'type',
    )
def test_description_keyword_is_not_required(msg_assertions):
    try:
        external_docs_validator({})
    except ValidationError as err:
        errors = err.detail
    else:
        errors = {}

    msg_assertions.assert_path_not_in_errors('description', errors)
def test_external_docs_type_validation_with_correct_type(msg_assertions):
    try:
        external_docs_validator({})
    except ValidationError as err:
        errors = err.detail
    else:
        errors = {}

    msg_assertions.assert_path_not_in_errors('type', errors)
def test_external_docs_type_validation(value, MESSAGES, msg_assertions):
    with pytest.raises(ValidationError) as err:
        external_docs_validator(value)

    msg_assertions.assert_message_in_errors(
        MESSAGES['type']['invalid'],
        err.value.detail,
        'type',
    )
Exemple #9
0
def test_url_keyword_must_be_a_uri_formatted(msg_assertions, MESSAGES):
    with pytest.raises(ValidationError) as err:
        external_docs_validator({
            'url': 'not-a-valid-url',
        })

    msg_assertions.assert_message_in_errors(
        MESSAGES['format']['invalid_uri'],
        err.value.detail,
        'url.format',
    )
def test_url_keyword_must_be_a_uri_formatted(msg_assertions, MESSAGES):
    with pytest.raises(ValidationError) as err:
        external_docs_validator({
            'url': 'not-a-valid-url',
        })

    msg_assertions.assert_message_in_errors(
        MESSAGES['format']['invalid_uri'],
        err.value.detail,
        'url.format',
    )
Exemple #11
0
def test_valid_external_docs_object(msg_assertions):
    external_docs_validator({
        'url': 'http://www.example.com',
        'description': 'A test description',
    })
def test_valid_external_docs_object(msg_assertions):
    external_docs_validator({
        'url': 'http://www.example.com',
        'description': 'A test description',
    })