Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_12_validate__ng(self):
(ret, msg) = TT.validate({'a': "aaa"}, self.schema)
self.assertTrue(msg)
self.assertFalse(ret)
def test_42_gen_schema_and_validate(self):
scm = _gen_scm(self.obj)
self.assertTrue(TT.validate(self.obj, scm))
def test_10_validate(self):
(ret, msg) = TT.validate(self.obj, self.schema)
self.assertFalse(msg)
self.assertTrue(ret)
def test_46_gen_schema_and_validate__complex_types(self):
scm = TT.gen_schema(self.obj2)
self.assertTrue(TT.validate(self.obj2, scm))
def _try_validate(cnf, schema, **options):
"""
:param cnf: Mapping object represents configuration data
:param schema: JSON schema object
:param options: Keyword options passed to :func:`jsonschema.validate`
:return: Given 'cnf' as it is if validation succeeds else None
"""
valid = True
if schema:
(valid, msg) = validate(cnf, schema, **options)
if msg:
LOGGER.warning(msg)
if valid:
return cnf
return None