fix moderation test
@@ -36,52 +36,56 @@ class PostTest(TestCase):
data = {"action": action}
data.update(extra)
- url = reverse('post_moderate', kwargs=dict(uid=self.uid))
+ url = reverse('post_moderate', kwargs=dict(uid=post.uid))
request = fake_request(url=url, data=data, user=self.owner)
response = views.post_moderate(request=request, uid=post.uid)
self.process_response(response)
return
- @patch('biostar.recipes.models.Job.save', MagicMock(name="save"))
+ @patch('biostar.forum.models.Post.save', MagicMock(name="save"))
def test_toplevel_moderation(self):
"Test top level post moderation."
# Test every moderation action
choices = [const.BUMP_POST, const.OPEN_POST, const.DELETE]
- #self.moderate(choices=choices, post=self.post)
+ self.post = models.Post.objects.create(title="Test",
+ author=self.owner, content="Test",
+ type=models.Post.QUESTION, uid='bar')
+ self.post.save()
- return
+ self.moderate(choices=choices, post=self.post)
+ @patch('biostar.forum.models.Post.save', MagicMock(name="save"))
def test_answer_moderation(self):
"Test answer moderation."
choices = [const.TOGGLE_ACCEPT, const.DELETE]
# Create an answer to moderate
answer = models.Post.objects.create(title="Test", author=self.owner, content="Test",
- type=models.Post.ANSWER, root=self.post,
+ type=models.Post.ANSWER, root=self.post, uid='foo2',
parent=self.post)
-
-
answer.save()
-
- #self.moderate(choices=choices, post=answer)
+ # Add the same amount of giving of the
+ self.moderate(choices=choices, post=answer)
return
+ @patch('biostar.forum.models.Post.save', MagicMock(name="save"))
def test_comment_moderation(self):
"Test comment moderation."
choices = [const.DELETE]
# Create a comment to moderate
comment = models.Post.objects.create(title="Test", author=self.owner, content="Test",
- type=models.Post.COMMENT, root=self.post,
+ type=models.Post.COMMENT, root=self.post, uid='foo3',
parent=self.post)
comment.save()
- #self.moderate(choices=choices, post=comment, extra={'pid': self.post.uid})
+ self.moderate(choices=choices, post=comment, extra={'pid': self.post.uid})
+ @patch('biostar.forum.models.Post.save', MagicMock(name="save"))
def test_duplicate_post(self):
"Test duplicate post moderation"
