def test_idmap(self): doc = { "type": "record", "fields": { "hello": { "doc": "Hello test case", "type": "string" } } } rs = cg_metaschema.RecordSchema(doc, "http://example.com/", cg_metaschema.LoadingOptions()) self.assertEqual("record", rs.type) self.assertEqual("http://example.com/#hello", rs.fields[0].name) self.assertEqual("Hello test case", rs.fields[0].doc) self.assertEqual("string", rs.fields[0].type) self.assertEqual( { "type": "record", "fields": [{ "name": "http://example.com/#hello", "doc": "Hello test case", "type": "string" }] }, rs.save())
def test_err2(self): doc = { "type": "rucord", "fields": [{ "name": "hello", "doc": "Hello test case", "type": "string" }] } with self.assertRaises(cg_metaschema.ValidationException): rs = cg_metaschema.RecordSchema(doc, "", cg_metaschema.LoadingOptions())
def test_import(self): doc = {"type": "record", "fields": [{"$import": "hellofield.yml"}]} lead = file_uri(os.path.normpath(get_data("tests"))) rs = cg_metaschema.RecordSchema( doc, "http://example.com/", cg_metaschema.LoadingOptions(fileuri=lead + "/_")) self.assertEqual("record", rs.type) self.assertEqual(lead + "/hellofield.yml#hello", rs.fields[0].name) self.assertEqual("hello world!\n", rs.fields[0].doc) self.assertEqual("string", rs.fields[0].type) self.assertEqual( { "type": "record", "fields": [{ "name": lead + "/hellofield.yml#hello", "doc": "hello world!\n", "type": "string" }] }, rs.save())