mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
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:
commit
e03aed58e8
1 changed files with 16 additions and 4 deletions
|
@ -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())
|
||||
|
|
Loading…
Add table
Reference in a new issue