def test_schema_multi_expand(self): test_schema = { 'schema1': { '$ref': '#/definitions/filters_common/value_from' }, 'schema2': { '$ref': '#/definitions/filters_common/value_from' } } expected = yaml_dump({ 'schema1': { 'type': 'object', 'additionalProperties': 'False', 'required': ['url'], 'properties': { 'url': { 'type': 'string' }, 'format': { 'enum': ['csv', 'json', 'txt', 'csv2dict'] }, 'expr': { 'oneOf': [{ 'type': 'integer' }, { 'type': 'string' }] } } }, 'schema2': { 'type': 'object', 'additionalProperties': 'False', 'required': ['url'], 'properties': { 'url': { 'type': 'string' }, 'format': { 'enum': ['csv', 'json', 'txt', 'csv2dict'] }, 'expr': { 'oneOf': [{ 'type': 'integer' }, { 'type': 'string' }] } } } }) result = yaml_dump( _expand_schema(test_schema, generate()['definitions'])) self.assertEquals(result, expected)
def test_schema_expand_not_found(self): test_schema = {'$ref': '#/definitions/filters_common/invalid_schema'} result = _expand_schema(test_schema, generate()['definitions']) self.assertEquals(result, None)
def test_schema_expand(self): # refs should only ever exist in a dictionary by itself test_schema = {'$ref': '#/definitions/filters_common/value_from'} result = _expand_schema(test_schema, generate()['definitions']) self.assertEquals(result, ValuesFrom.schema)