Skip to content

Commit

Permalink
Merge pull request #52591 from Ch3LL/fix_jsonschema_2019.2
Browse files Browse the repository at this point in the history
[2019.2.1] Update test_schema to mirror the new ValidationErrors in 3.0.0
  • Loading branch information
dwoz authored Apr 18, 2019
2 parents 21d6365 + e09be84 commit e03aed5
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions tests/unit/utils/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,10 @@ class Requirements(BaseRequirements):
{'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?')
Expand Down Expand Up @@ -1730,7 +1733,10 @@ class TestConf(schema.Schema):

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(
Expand Down Expand Up @@ -1833,7 +1839,10 @@ class TestConf(schema.Schema):

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())
Expand Down Expand Up @@ -1885,7 +1894,10 @@ class TestConf(schema.Schema):

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())
Expand Down

0 comments on commit e03aed5

Please sign in to comment.