##// END OF EJS Templates
Fixed the tests. Added exists() method for the post.
neko259 -
r8:b62ef70f default
parent child Browse files
Show More
@@ -45,6 +45,11 b' class PostManager(models.Manager):'
45 45
46 46 return [opening_post, replies]
47 47
48 def exists(self, post_id):
49 posts = Post.objects.filter(id = post_id)
50
51 return len(posts) == 0
52
48 53
49 54 class Tag(models.Model):
50 55 """
@@ -54,6 +59,7 b' class Tag(models.Model):'
54 59
55 60 name = models.CharField(max_length = 100)
56 61
62
57 63 class Post(models.Model):
58 64 """A post is a message."""
59 65
@@ -3,6 +3,7 b' import boards'
3 3
4 4 from boards.models import Post
5 5
6
6 7 class BoardTests(TestCase):
7 8
8 9 def create_post(self):
@@ -17,14 +18,16 b' class BoardTests(TestCase):'
17 18
18 19 def test_delete_post(self):
19 20 post = self.create_post()
21 post_id = post.id
20 22
21 23 Post.objects.delete_post(post)
22 24
23 self.assertIsNone(post)
25 self.assertTrue(Post.objects.exists(post_id))
24 26
25 27 def test_delete_posts_by_ip(self):
26 28 post = self.create_post()
29 post_id = post.id
27 30
28 31 Post.objects.delete_posts_by_ip('0.0.0.0')
29 32
30 self.assertIsNone(post)
33 self.assertTrue(Post.objects.exists(post_id))
General Comments 0
You need to be logged in to leave comments. Login now