def test_comment_traversal(self): """Test comment rendering pages""" # Create a couple of comments to traverse comment = models.Post.objects.create(title="Test", author=self.owner, content="Test", type=models.Post.COMMENT, root=self.post, parent=self.post) comment2 = models.Post.objects.create(title="Test", author=self.owner, content="Test", type=models.Post.COMMENT, root=self.post, parent=comment) url = reverse("post_view", kwargs=dict(uid=self.post.uid)) request = fake_request(url=url, data={}, user=self.owner) response = views.post_view(request=request, uid=self.post.uid) self.assertTrue(response.status_code == 200, 'Error rendering comments')
def test_post_answer(self): """ Test submitting answer through the post view """ url = reverse("post_view", kwargs=dict(uid=self.post.uid)) # Get form data data = dict(content="testing answer", parent_uid=self.post.uid) request = fake_request(url=url, data=data, user=self.owner) response = views.post_view(request=request, uid=self.post.uid) return
def discussion_view(request, uid): template = "discussion_view.html" # Get the parents info obj = Post.objects.get_discussions(uid=uid).first() project = obj.root.project sub_url = reverse("discussion_subs", kwargs=dict(uid=obj.uid)) next_url = reverse("discussion_view", kwargs=dict(uid=obj.uid)) context = dict(project=project, activate="Discussion", sub_url=sub_url, next_url=next_url) counts = get_counts(project) context.update(counts) return forum_views.post_view(request=request, template=template, extra_context=context, url="discussion_view", uid=uid)