def test_title_is_mandatory(self): document = Document(description='test_description', body='test_body', user=self.test_user) with self.assertRaises(ValidationError): document.full_clean()
def test_body_is_not_mandatory(self): document = Document(title='test_title', description='test_description', user=self.test_user) try: document.full_clean() except ValidationError: self.fail('Document is not correct.')
def test_description_max_length(self): description_max_length = Document.description.field.max_length self.assertEqual(description_max_length, 100) description = 'a' * 101 document = Document(title='test_title', description=description, body='test_body', user=self.test_user) with self.assertRaises(ValidationError): document.full_clean()
def test_title_max_length(self): title_max_length = Document.title.field.max_length self.assertEqual(title_max_length, 50) title = 'a' * 51 document = Document(title=title, description='test_description', body='test_body', user=self.test_user) with self.assertRaises(ValidationError): document.full_clean()
def test_description_limit_max_length(self): description_max_length = Document.description.field.max_length self.assertEqual(description_max_length, 100) description = 'a' * 100 document = Document(title='test_title', description=description, body='test_body', user=self.test_user) try: document.full_clean() except ValidationError: self.fail('Document is not correct.')
def test_title_limit_max_length(self): title_max_length = Document.title.field.max_length self.assertEqual(title_max_length, 50) title = 'a' * 50 document = Document(title=title, description='test_description', body='test_body', user=self.test_user) try: document.full_clean() except ValidationError: self.fail('Document is not correct.')