def test_cannot_create_post_without_body(self): blog_post = BlogPost(title="", date=datetime.datetime.now(), body="", visible=True) with self.assertRaises(ValidationError): blog_post.full_clean()
def test_user_cannot_be_normal(self): count = BlogPost.objects.count() with self.assertRaises(ValidationError): post = BlogPost(author=self.normal, title="foo", content="bar") post.full_clean() self.assertEqual(count, BlogPost.objects.count())
def test_cannot_create_two_posts_with_same_date(self): today = datetime.datetime.now().date() BlogPost.objects.create(title=".", date=today, body=".", visible=True) with self.assertRaises(ValidationError): post = BlogPost(title=".", date=today, body=".", visible=True) post.full_clean()
def test_cannot_create_two_posts_with_same_date(self): today = datetime.datetime.now().date() BlogPost.objects.create(title=".", date=today, body=".", visible=True) with self.assertRaises(ValidationError): post = BlogPost(title=".", date=today, body=".", visible=True) post.full_clean()
def test_cannot_create_post_without_body(self): blog_post = BlogPost(title="", date=datetime.datetime.now(), body="", visible=True) with self.assertRaises(ValidationError): blog_post.full_clean()