Exemple #1
0
 def test_jsonschema_error_message_required_single_property(self):
     error_message = _jsonschema_error_message(
         _TestJsonSchemaValidationError(validator='required',
                                        validator_value=['foo', 'bar'],
                                        instance={'foo': None},
                                        relative_path=[]))
     self.assertEqual(error_message, 'required property bar is missing')
Exemple #2
0
 def test_jsonschema_error_message_required_multiple_properties(self):
     error_message = _jsonschema_error_message(
         _TestJsonSchemaValidationError(validator='required',
                                        validator_value=['foo', 'bar'],
                                        instance={},
                                        relative_path=[]))
     self.assertEqual(error_message,
                      'required properties [bar, foo] are missing')
Exemple #3
0
 def test_jsonschema_error_message_uniqueItems(self):
     error_message = _jsonschema_error_message(
         _TestJsonSchemaValidationError(validator='uniqueItems',
                                        instance=[None, None],
                                        relative_path=['foo']))
     self.assertEqual(
         error_message,
         'array property foo has duplicate items at index [0, 1]')
Exemple #4
0
 def test_jsonschema_error_message_type_null_single_type(self):
     error_message = _jsonschema_error_message(
         _TestJsonSchemaValidationError(validator='type',
                                        validator_value='string',
                                        instance=None,
                                        relative_path=['foo']))
     self.assertEqual(
         error_message,
         'property foo with null value should be of type string')
Exemple #5
0
 def test_jsonschema_error_message_maxItems(self):
     error_message = _jsonschema_error_message(
         _TestJsonSchemaValidationError(validator='maxItems',
                                        validator_value=0,
                                        instance=[None],
                                        relative_path=['foo']))
     self.assertEqual(
         error_message,
         'array property foo with 1 items is too large, maximum size 0')
Exemple #6
0
 def test_jsonschema_error_message_minItems(self):
     error_message = _jsonschema_error_message(
         _TestJsonSchemaValidationError(validator='minItems',
                                        validator_value=1,
                                        instance=[],
                                        relative_path=['foo']))
     self.assertEqual(
         error_message,
         'array property foo with 0 items is too small, minimum size 1')
Exemple #7
0
 def test_jsonschema_error_message_type_single_type(self):
     error_message = _jsonschema_error_message(
         _TestJsonSchemaValidationError(validator='type',
                                        validator_value='string',
                                        instance=1,
                                        relative_path=['foo']))
     self.assertEqual(
         error_message,
         'property type integer for property foo is not the allowed type: string'
     )
Exemple #8
0
 def test_jsonschema_error_message_pattern(self):
     error_message = _jsonschema_error_message(
         _TestJsonSchemaValidationError(validator='pattern',
                                        validator_value='^a$',
                                        instance='',
                                        relative_path=['foo']))
     self.assertEqual(
         error_message,
         "property value '' for foo property does not match the pattern '^a$'"
     )
Exemple #9
0
 def test_jsonschema_error_message_maxLength(self):
     error_message = _jsonschema_error_message(
         _TestJsonSchemaValidationError(validator='maxLength',
                                        validator_value=0,
                                        instance=' ',
                                        relative_path=['foo']))
     self.assertEqual(
         error_message,
         "property value ' ' for foo property is too long, maximum length 0"
     )
Exemple #10
0
 def test_jsonschema_error_message_maximum(self):
     error_message = _jsonschema_error_message(
         _TestJsonSchemaValidationError(validator='maximum',
                                        validator_value=0,
                                        instance=1,
                                        relative_path=['foo']))
     self.assertEqual(
         error_message,
         'property value 1 for foo property is greater than the maximum value of 0'
     )
Exemple #11
0
 def test_jsonschema_error_message_type_multiple_types(self):
     error_message = _jsonschema_error_message(
         _TestJsonSchemaValidationError(
             validator='type',
             validator_value=['integer', 'string'],
             instance=[],
             relative_path=['foo']))
     self.assertEqual(
         error_message,
         'property type array for property foo is not one of the allowed types: [integer, string]'
     )
Exemple #12
0
 def test_jsonschema_error_message_type_null_multiple_types(self):
     error_message = _jsonschema_error_message(
         _TestJsonSchemaValidationError(
             validator='type',
             validator_value=['integer', 'string'],
             instance=None,
             relative_path=['foo']))
     self.assertEqual(
         error_message,
         'property foo with null value should be one of the allowed types: [integer, string]'
     )
Exemple #13
0
 def test_jsonschema_error_message_additionalProperties_multiple_properties(
         self):
     error_message = _jsonschema_error_message(
         _TestJsonSchemaValidationError(validator='additionalProperties',
                                        schema={'properties': {}},
                                        instance={
                                            'foo': None,
                                            'bar': None
                                        },
                                        relative_path=[]))
     self.assertEqual(error_message,
                      'additional properties [bar, foo] are not allowed')
Exemple #14
0
 def test_jsonschema_error_message_unknown(self):
     error_message = _jsonschema_error_message(
         _TestJsonSchemaValidationError(validator='UNKNOWN',
                                        message='an error message',
                                        relative_path=[]))
     self.assertEqual(error_message, 'an error message')