def test_validate_raises_error_when_invalid(self): with self.assertRaises(pkgschema.ValidationError): pkgschema.validate_schema(self.schema, {}) with self.assertRaises(pkgschema.ValidationError): pkgschema.validate_schema(self.schema, {'test': 1}) with self.assertRaises(pkgschema.ValidationError): pkgschema.validate_schema(self.schema, {'test': 'ok', 'extra': 2})
def test_exception_string_returns_string(self): try: pkgschema.validate_schema(self.schema, {}) except pkgschema.ValidationError as err: self.assertIsInstance(str(err), str)
def test_validate_returns_None_when_valid(self): obj = {'test': 'ok'} self.assertIsNone(pkgschema.validate_schema(self.schema, obj))
def test_full_metadata(self): obj = Object(self.full_options) metadata = obj.to_metadata() self.assertEqual(self.full_metadata, metadata) self.assertIsNone(validate_schema(self.mode_schema, metadata))