Example #1
0
    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)
Example #2
0
def _gen_scm(val):
    return TT.gen_schema(val, ac_schema_strict=True)
Example #3
0
 def test_44_gen_schema__complex_types(self):
     scm = TT.gen_schema(self.obj2)
     self.assertEqual(scm, self.ref_scm)
Example #4
0
 def test_46_gen_schema_and_validate__complex_types(self):
     scm = TT.gen_schema(self.obj2)
     self.assertTrue(TT.validate(self.obj2, scm))
Example #5
0
 def test_42_gen_schema_and_validate(self):
     scm = TT.gen_schema(self.obj)
     self.assertTrue(TT.validate(self.obj, scm))