Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _gen_scm(val):
return TT.gen_schema(val, ac_schema_strict=True)
def test_42_gen_schema_and_validate(self):
scm = TT.gen_schema(self.obj)
self.assertTrue(TT.validate(self.obj, scm))
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.assertTrue(dicts_equal(scm, ref_scm))
scm = TT.gen_schema({'a': 1})
ref_scm = {'properties': {'a': {'type': 'integer'}}, 'type': 'object'}
self.assertTrue(dicts_equal(scm, ref_scm))
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.assertTrue(dicts_equal(scm, ref_scm))
scm = TT.gen_schema({'a': 1})
ref_scm = {'properties': {'a': {'type': 'integer'}}, 'type': 'object'}
self.assertTrue(dicts_equal(scm, ref_scm))
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.assertTrue(dicts_equal(scm, ref_scm))
scm = TT.gen_schema({'a': 1})
ref_scm = {'properties': {'a': {'type': 'integer'}}, 'type': 'object'}
self.assertTrue(dicts_equal(scm, ref_scm))
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.assertTrue(dicts_equal(scm, ref_scm))
scm = TT.gen_schema({'a': 1})
ref_scm = {'properties': {'a': {'type': 'integer'}}, 'type': 'object'}
self.assertTrue(dicts_equal(scm, ref_scm))
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.assertTrue(dicts_equal(scm, ref_scm))
scm = TT.gen_schema({'a': 1})
ref_scm = {'properties': {'a': {'type': 'integer'}}, 'type': 'object'}
self.assertTrue(dicts_equal(scm, 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))