示例#1
0
def test_valid(schema, schemas, expected_schema):
    """
    GIVEN given schema, schemas and expected schema
    WHEN merge is called with the schema and schemas
    THEN the expected schema is returned.
    """
    return_schema = all_of.merge(schema=schema, schemas=schemas)

    assert return_schema == expected_schema
示例#2
0
def test_backrefs(all_of_schema, expected_backrefs):
    """
    GIVEN schema that has allOf with schemas with given backrefs and expected
        backrefs
    WHEN merge is called with the schema
    THEN the returned schema has the expected backrefs.
    """
    schema = {"allOf": all_of_schema}
    schemas = {}

    return_schema = all_of.merge(schema=schema, schemas=schemas)

    assert return_schema["x-backrefs"] == expected_backrefs
示例#3
0
def test_properties(all_of_schema, expected_properties):
    """
    GIVEN schema that has allOf with schemas with given properties and expected
        properties
    WHEN merge is called with the schema
    THEN the returned schema has the expected properties.
    """
    schema = {"allOf": all_of_schema}
    schemas = {}

    return_schema = all_of.merge(schema=schema, schemas=schemas)

    assert return_schema["properties"] == expected_properties
示例#4
0
def test_required(all_of_schema, expected_required):
    """
    GIVEN schema that has allOf with schemas with given required properties and expected
        final required
    WHEN merge is called with the schema
    THEN the returned schema has the expected required property.
    """
    schema = {"allOf": all_of_schema}
    schemas = {}

    return_schema = all_of.merge(schema=schema, schemas=schemas)

    assert sorted(return_schema["required"]) == sorted(expected_required)
示例#5
0
def test_skip(schema, schemas, expected_schema):
    """
    GIVEN given schema, schemas and expected schema
    WHEN merge is called with the schema and schemas and skip name
    THEN the expected schema is returned.
    """
    skip_name = "RefSchema"

    return_schema = all_of.merge(schema=schema,
                                 schemas=schemas,
                                 skip_name=skip_name)

    assert return_schema == expected_schema