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)
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)
def test_dynamic_function_correct_type(self): self.document_1['website'] = "WEB" blog_post_schema.validate(self.document_1)
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)
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)
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)
def test_non_required_field_set_to_none(self): self.document_1['likes'] = None blog_post_schema.validate(self.document_1)
def test_valid_document_2(self): blog_post_schema.validate(self.document_2)
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)
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)
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)
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())