예제 #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,
    )