Merge pull request #52591 from Ch3LL/fix_jsonschema_2019.2

[2019.2.1] Update test_schema to mirror the new ValidationErrors in 3.0.0
This commit is contained in:
Daniel Wozniak 2019-04-18 09:34:21 -07:00 committed by GitHub
commit e03aed58e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -506,7 +506,10 @@ class ConfigTestCase(TestCase):
{'personal_access_token': 'foo'},
Requirements.serialize()
)
self.assertIn('is not valid under any of the given schemas', excinfo.exception.message)
if JSONSCHEMA_VERSION >= _LooseVersion('3.0.0'):
self.assertIn('\'ssh_key_file\' is a required property', excinfo.exception.message)
else:
self.assertIn('is not valid under any of the given schemas', excinfo.exception.message)
def test_boolean_config(self):
item = schema.BooleanItem(title='Hungry', description='Are you hungry?')
@ -1730,7 +1733,10 @@ class ConfigTestCase(TestCase):
with self.assertRaises(jsonschema.exceptions.ValidationError) as excinfo:
jsonschema.validate({'item': {'sides': '4', 'color': 'blue'}}, TestConf.serialize())
self.assertIn('is not valid under any of the given schemas', excinfo.exception.message)
if JSONSCHEMA_VERSION >= _LooseVersion('3.0.0'):
self.assertIn('\'4\' is not of type \'boolean\'', excinfo.exception.message)
else:
self.assertIn('is not valid under any of the given schemas', excinfo.exception.message)
class TestConf(schema.Schema):
item = schema.DictItem(
@ -1833,7 +1839,10 @@ class ConfigTestCase(TestCase):
with self.assertRaises(jsonschema.exceptions.ValidationError) as excinfo:
jsonschema.validate({'item': ['maybe']}, TestConf.serialize())
self.assertIn('is not valid under any of the given schemas', excinfo.exception.message)
if JSONSCHEMA_VERSION >= _LooseVersion('3.0.0'):
self.assertIn('\'maybe\' is not one of [\'yes\']', excinfo.exception.message)
else:
self.assertIn('is not valid under any of the given schemas', excinfo.exception.message)
with self.assertRaises(jsonschema.exceptions.ValidationError) as excinfo:
jsonschema.validate({'item': 2}, TestConf.serialize())
@ -1885,7 +1894,10 @@ class ConfigTestCase(TestCase):
with self.assertRaises(jsonschema.exceptions.ValidationError) as excinfo:
jsonschema.validate({'item': ['maybe']}, TestConf.serialize())
self.assertIn('is not valid under any of the given schemas', excinfo.exception.message)
if JSONSCHEMA_VERSION >= _LooseVersion('3.0.0'):
self.assertIn('\'maybe\' is not one of [\'yes\']', excinfo.exception.message)
else:
self.assertIn('is not valid under any of the given schemas', excinfo.exception.message)
with self.assertRaises(jsonschema.exceptions.ValidationError) as excinfo:
jsonschema.validate({'item': 2}, TestConf.serialize())