示例#1
0
def test_schema_with_valid_value(msg_assertions):
    try:
        single_response_validator({'schema': {}})
    except ValidationError as err:
        errors = err.detail
    else:
        errors = {}

    msg_assertions.assert_path_not_in_errors('schema', errors)
示例#2
0
def test_schema_is_not_required(msg_assertions):
    try:
        single_response_validator({})
    except ValidationError as err:
        errors = err.detail
    else:
        errors = {}

    msg_assertions.assert_path_not_in_errors('schema', errors)
示例#3
0
def test_headers_validation_with_valid_type():
    try:
        single_response_validator({'headers': {}})
    except ValidationError as err:
        errors = err.detail
    else:
        errors = {}

    assert_path_not_in_errors('headers', errors)
示例#4
0
def test_schema_type_validation(value, MESSAGES, msg_assertions):
    with pytest.raises(ValidationError) as err:
        single_response_validator({'schema': value})

    msg_assertions.assert_message_in_errors(
        MESSAGES['type']['invalid'],
        err.value.detail,
        'schema.type',
    )
示例#5
0
def test_headers_is_not_required():
    try:
        single_response_validator({})
    except ValidationError as err:
        errors = err.detail
    else:
        errors = {}

    assert_path_not_in_errors('headers', errors)
示例#6
0
def test_schema_type_validation(value, MESSAGES, msg_assertions):
    with pytest.raises(ValidationError) as err:
        single_response_validator({'schema': value})

    msg_assertions.assert_message_in_errors(
        MESSAGES['type']['invalid'],
        err.value.detail,
        'schema.type',
    )
示例#7
0
def test_schema_with_valid_value(msg_assertions):
    try:
        single_response_validator({'schema': {}})
    except ValidationError as err:
        errors = err.detail
    else:
        errors = {}

    msg_assertions.assert_path_not_in_errors('schema', errors)
示例#8
0
def test_schema_is_not_required(msg_assertions):
    try:
        single_response_validator({})
    except ValidationError as err:
        errors = err.detail
    else:
        errors = {}

    msg_assertions.assert_path_not_in_errors('schema', errors)
示例#9
0
def test_headers_validation_with_invalid_types(value):
    context = {'deferred_references': set()}

    with pytest.raises(ValidationError) as err:
        single_response_validator({'headers': value}, context=context)

    assert_message_in_errors(
        MESSAGES['type']['invalid'],
        err.value.detail,
        'headers.type',
    )
示例#10
0
def test_schema_validation_with_invalid_types(value):
    context = {'deferred_references': set()}

    response_definition = ResponseDefinitionFactory(schema=value)
    with pytest.raises(ValidationError) as err:
        single_response_validator(response_definition, context=context)

    assert_message_in_errors(
        MESSAGES['type']['invalid'],
        err.value.detail,
        'schema.type',
    )
示例#11
0
def test_schema_validation_with_invalid_types(value):
    context = {'deferred_references': set()}

    response_definition = ResponseDefinitionFactory(schema=value)
    with pytest.raises(ValidationError) as err:
        single_response_validator(response_definition, context=context)

    assert_message_in_errors(
        MESSAGES['type']['invalid'],
        err.value.detail,
        'schema.type',
    )
示例#12
0
def test_schema_is_not_required():
    context = {'deferred_references': set()}
    response_definition = ResponseDefinitionFactory()
    response_definition.pop('schema', None)
    try:
        single_response_validator(response_definition, context=context)
    except ValidationError as err:
        errors = err.detail
    else:
        errors = {}

    assert_path_not_in_errors(
        'schema',
        errors,
    )
示例#13
0
def test_schema_is_not_required():
    context = {'deferred_references': set()}
    response_definition = ResponseDefinitionFactory()
    response_definition.pop('schema', None)
    try:
        single_response_validator(response_definition, context=context)
    except ValidationError as err:
        errors = err.detail
    else:
        errors = {}

    assert_path_not_in_errors(
        'schema',
        errors,
    )