Пример #1
0
    def test_schema_level_validator_list_item_just_right(self):
        self.document_1.update(
            {'creation_date': datetime(2014, 1, 1),
             'modification_date': datetime(2015, 1, 1),
             'final_date': datetime(2016, 1, 1)})

        blog_post_schema.validate(self.document_1)
Пример #2
0
    def test_schema_level_validator_list_item_just_right(self):
        self.document_1.update({
            'creation_date': datetime(2014, 1, 1),
            'modification_date': datetime(2015, 1, 1),
            'final_date': datetime(2016, 1, 1)
        })

        blog_post_schema.validate(self.document_1)
Пример #3
0
 def test_dynamic_function_correct_type(self):
     self.document_1['website'] = "WEB"
     blog_post_schema.validate(self.document_1)
Пример #4
0
 def test_dynamic_function_valid_array(self):
     self.document_1['website'] = [
         self.document_1['website'] for i in range(2)
     ]
     blog_post_schema.validate(self.document_1)
Пример #5
0
 def test_mixed_type(self):
     self.document_1['misc'] = "a string"
     blog_post_schema.validate(self.document_1)
     self.document_1['misc'] = 32
     blog_post_schema.validate(self.document_1)
Пример #6
0
 def test_dynamic_function_exception(self):
     self.document_1['author'] = 33
     with self.assertRaises(SchemaFormatException) as cm:
         blog_post_schema.validate(self.document_1)
     self.assertEqual('author', cm.exception.path)
Пример #7
0
 def test_non_required_field_set_to_none(self):
     self.document_1['likes'] = None
     blog_post_schema.validate(self.document_1)
Пример #8
0
 def test_valid_document_2(self):
     blog_post_schema.validate(self.document_2)
Пример #9
0
 def test_valid_document_2(self):
     blog_post_schema.validate(self.document_2)
Пример #10
0
 def test_array_with_dynamic_function_heterogenous_list_correct_type(self):
     self.document_1['editors'] = [{'first': 'Jordan', 'last': 'Gansey'}, 'Jordan Gansey']
     blog_post_schema.validate(self.document_1)
Пример #11
0
 def test_dynamic_function_correct_type(self):
     self.document_1['website'] = "WEB"
     blog_post_schema.validate(self.document_1)
Пример #12
0
 def test_dynamic_function_valid_array(self):
     self.document_1['website'] = [self.document_1['website'] for i in range(2)]
     blog_post_schema.validate(self.document_1)
Пример #13
0
 def test_mixed_type(self):
     self.document_1['misc'] = "a string"
     blog_post_schema.validate(self.document_1)
     self.document_1['misc'] = 32
     blog_post_schema.validate(self.document_1)
Пример #14
0
 def test_dynamic_function_exception(self):
     self.document_1['author'] = 33
     with self.assertRaises(SchemaFormatException) as cm:
         blog_post_schema.validate(self.document_1)
     self.assertEqual('author', cm.exception.path)
Пример #15
0
 def test_non_required_field_set_to_none(self):
     self.document_1['likes'] = None
     blog_post_schema.validate(self.document_1)
Пример #16
0
 def test_array_with_dynamic_function_heterogenous_list_correct_type(self):
     self.document_1['editors'] = [{
         'first': 'Jordan',
         'last': 'Gansey'
     }, 'Jordan Gansey']
     blog_post_schema.validate(self.document_1)
Пример #17
0
 def assert_document_paths_invalid(self, document, paths):
     with self.assertRaises(ValidationException) as cm:
         blog_post_schema.validate(document)
     self.assertListEqual(paths, cm.exception.errors.keys())
Пример #18
0
 def assert_document_paths_invalid(self, document, paths):
     with self.assertRaises(ValidationException) as cm:
         blog_post_schema.validate(document)
     self.assertListEqual(paths, cm.exception.errors.keys())