Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2019.2.1] Update test_schema to mirror the new ValidationErrors in 3.0.0 #52591

Merged
merged 1 commit into from Apr 18, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 16 additions & 4 deletions tests/unit/utils/test_schema.py
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