def test_40_gen_schema__primitive_types(self): self.assertEqual(TT.gen_schema(None), {'type': 'null'}) self.assertEqual(TT.gen_schema(0), {'type': 'integer'}) self.assertEqual(TT.gen_schema("aaa"), {'type': 'string'}) scm = TT.gen_schema([1]) ref_scm = {'items': {'type': 'integer'}, 'type': 'array'} self.assertEqual(scm, ref_scm) scm = TT.gen_schema({'a': 1}) ref_scm = {'properties': {'a': {'type': 'integer'}}, 'type': 'object'} self.assertEqual(scm, ref_scm)
def _gen_scm(val): return TT.gen_schema(val, ac_schema_strict=True)
def test_44_gen_schema__complex_types(self): scm = TT.gen_schema(self.obj2) self.assertEqual(scm, self.ref_scm)
def test_46_gen_schema_and_validate__complex_types(self): scm = TT.gen_schema(self.obj2) self.assertTrue(TT.validate(self.obj2, scm))
def test_42_gen_schema_and_validate(self): scm = TT.gen_schema(self.obj) self.assertTrue(TT.validate(self.obj, scm))