Ejemplo n.º 1
0
def test_description_is_required(msg_assertions):
    with pytest.raises(ValidationError) as err:
        responses_validator({
            200: {},
        })

    msg_assertions.assert_message_in_errors(
        MESSAGES['required']['required'],
        err.value.detail,
        '200.required.description',
    )
Ejemplo n.º 2
0
def test_with_description(msg_assertions):
    try:
        responses_validator({
            200: {'description': 'A Description'},
        })
    except ValidationError as err:
        errors = err.detail
    else:
        errors = {}

    msg_assertions.assert_path_not_in_errors('200', errors)
Ejemplo n.º 3
0
def test_description_is_required(msg_assertions):
    with pytest.raises(ValidationError) as err:
        responses_validator({
            200: {},
        })

    msg_assertions.assert_message_in_errors(
        MESSAGES['required']['required'],
        err.value.detail,
        '200.required.description',
    )
Ejemplo n.º 4
0
def test_with_missing_reference(msg_assertions):
    responses = {
        200: {'$ref': '#/responses/UnknownReference'},
    }
    with pytest.raises(ValidationError) as err:
        responses_validator(responses, context={})

    msg_assertions.assert_message_in_errors(
        MESSAGES['reference']['undefined'],
        err.value.detail,
        '200.$ref',
    )
Ejemplo n.º 5
0
def test_response_as_external_reference_missing_description(msg_assertions):
    responses = {
        200: {
            '$ref': 'jsonschemas/responses_description.json#'
        },
    }
    context = {}
    try:
        responses_validator(responses, context=context, base_path=DIR)
    except ValidationError as err:
        errors = err.detail
    else:
        errors = {}

    msg_assertions.assert_path_not_in_errors('200', errors)
Ejemplo n.º 6
0
def test_with_description_in_reference(msg_assertions):
    responses = {
        200: {'$ref': '#/responses/SomeResponse'},
    }
    context = {
        'responses': {
            'SomeResponse': {'description': 'A Description'},
        },
    }
    try:
        responses_validator(responses, context=context)
    except ValidationError as err:
        errors = err.detail
    else:
        errors = {}

    msg_assertions.assert_path_not_in_errors('200', errors)