コード例 #1
0
ファイル: exceptions_tests.py プロジェクト: Noblis/ties-lib
 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')
コード例 #2
0
ファイル: exceptions_tests.py プロジェクト: Noblis/ties-lib
 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')
コード例 #3
0
ファイル: exceptions_tests.py プロジェクト: Noblis/ties-lib
 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]')
コード例 #4
0
ファイル: exceptions_tests.py プロジェクト: Noblis/ties-lib
 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')
コード例 #5
0
ファイル: exceptions_tests.py プロジェクト: Noblis/ties-lib
 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')
コード例 #6
0
ファイル: exceptions_tests.py プロジェクト: Noblis/ties-lib
 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')
コード例 #7
0
ファイル: exceptions_tests.py プロジェクト: Noblis/ties-lib
 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'
     )
コード例 #8
0
ファイル: exceptions_tests.py プロジェクト: Noblis/ties-lib
 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$'"
     )
コード例 #9
0
ファイル: exceptions_tests.py プロジェクト: Noblis/ties-lib
 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"
     )
コード例 #10
0
ファイル: exceptions_tests.py プロジェクト: Noblis/ties-lib
 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'
     )
コード例 #11
0
ファイル: exceptions_tests.py プロジェクト: Noblis/ties-lib
 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]'
     )
コード例 #12
0
ファイル: exceptions_tests.py プロジェクト: Noblis/ties-lib
 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]'
     )
コード例 #13
0
ファイル: exceptions_tests.py プロジェクト: Noblis/ties-lib
 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')
コード例 #14
0
ファイル: exceptions_tests.py プロジェクト: Noblis/ties-lib
 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')