From e09be8425b5c3e3310607d3513c3513b74929985 Mon Sep 17 00:00:00 2001 From: Ch3LL Date: Wed, 17 Apr 2019 15:45:05 -0400 Subject: [PATCH] Update test_schema to mirror the new ValidationErrors in 3.0.0 --- tests/unit/utils/test_schema.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/tests/unit/utils/test_schema.py b/tests/unit/utils/test_schema.py index 677cd0778be6..a07fcbab6bce 100644 --- a/tests/unit/utils/test_schema.py +++ b/tests/unit/utils/test_schema.py @@ -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?') @@ -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( @@ -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()) @@ -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())