Exemplo n.º 1
0
 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()
Exemplo n.º 2
0
 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())
Exemplo n.º 3
0
 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()
Exemplo n.º 4
0
 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()
Exemplo n.º 5
0
 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()