Example #1
0
def test_paths_is_required():
    raw_schema = RawSchemaFactory()
    raw_schema.pop('paths', None)

    with pytest.raises(ValidationError) as err:
        swagger_schema_validator(raw_schema)

    assert_message_in_errors(
        MESSAGES['required']['required'],
        err.value.detail,
        'paths.required',
    )
Example #2
0
def test_paths_is_required():
    raw_schema = RawSchemaFactory()
    raw_schema.pop('paths', None)

    with pytest.raises(ValidationError) as err:
        swagger_schema_validator(raw_schema)

    assert_message_in_errors(
        MESSAGES['required']['required'],
        err.value.detail,
        'required.paths',
    )
def test_consumes_not_required():
    raw_schema = RawSchemaFactory()
    raw_schema.pop('consumes', None)

    try:
        swagger_schema_validator(raw_schema)
    except ValidationError as err:
        errors = err.detail
    else:
        errors = {}

    assert_path_not_in_errors(
        'consumes',
        errors,
    )
Example #4
0
def test_consumes_not_required():
    raw_schema = RawSchemaFactory()
    raw_schema.pop('consumes', None)

    try:
        swagger_schema_validator(raw_schema)
    except ValidationError as err:
        errors = err.detail
    else:
        errors = {}

    assert_path_not_in_errors(
        'consumes',
        errors,
    )
Example #5
0
def test_info_field_is_required():
    """
    Test that the info field is required for overall schema validation.
    """
    raw_schema = RawSchemaFactory()
    raw_schema.pop('info', None)

    assert 'info' not in raw_schema

    with pytest.raises(ValidationError) as err:
        swagger_schema_validator(raw_schema)

    assert_message_in_errors(
        MESSAGES['required']['required'],
        err.value.detail,
        'required.info',
    )
Example #6
0
def test_swagger_field_is_required():
    """
    Test that the info field is required for overall schema validation.
    """
    raw_schema = RawSchemaFactory()
    raw_schema.pop('swagger', None)

    assert 'swagger' not in raw_schema

    with pytest.raises(ValidationError) as err:
        swagger_schema_validator(raw_schema)

    assert_message_in_errors(
        MESSAGES['required']['required'],
        err.value.detail,
        'required.swagger',
    )
Example #7
0
def test_schemes_is_not_required():
    """
    Test that the info field is required for overall schema validation.
    """
    raw_schema = RawSchemaFactory()
    raw_schema.pop('schemes', None)

    assert 'schemes' not in raw_schema

    try:
        swagger_schema_validator(raw_schema)
    except ValidationError as err:
        errors = err.detail
    else:
        errors = {}

    assert_path_not_in_errors(
        'schemes',
        errors,
    )
Example #8
0
def test_base_path_is_not_required():
    """
    Test that the info field is required for overall schema validation.
    """
    raw_schema = RawSchemaFactory()
    raw_schema.pop('basePath', None)

    assert 'basePath' not in raw_schema

    try:
        swagger_schema_validator(raw_schema)
    except ValidationError as err:
        errors = err.detail
    else:
        errors = {}

    assert_path_not_in_errors(
        'basePath',
        errors,
    )