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
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
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
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)
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