def test_post(self, client, moderator): post = PostFactory(community=moderator.community) flag = FlagFactory( content_object=post, community=moderator.community, ) response = client.post(reverse("flags:delete", args=[flag.id])) assert response.url == post.get_absolute_url() assert not Flag.objects.exists()
def test_post(self, client, member): post = PostFactory(community=member.community) comment = CommentFactory( owner=member.member, content_object=post, community=member.community, ) response = client.post(reverse("comments:delete", args=[comment.id])) assert response.url == post.get_absolute_url() assert Comment.objects.count() == 0
def test_post(self, client, member, send_webpush_mock): post = PostFactory(community=member.community) parent = CommentFactory( content_object=post, community=member.community, owner=MembershipFactory(community=member.community).member, ) response = client.post(reverse("comments:reply", args=[parent.id]), {"content": "test"}) comment = Comment.objects.get(parent=parent) assert response.url == post.get_absolute_url() assert comment.owner == member.member assert comment.content_object == parent.content_object assert comment.parent == parent
def test_post_by_moderator(self, client, moderator, mailoutbox, send_webpush_mock): member = MembershipFactory(community=moderator.community) post = PostFactory(community=moderator.community, owner=member.member) comment = CommentFactory( owner=member.member, content_object=post, community=moderator.community, ) response = client.post(reverse("comments:delete", args=[comment.id])) assert response.url == post.get_absolute_url() assert Comment.objects.deleted().count() == 1 assert send_webpush_mock.delay.called assert len(mailoutbox) == 1 assert mailoutbox[0].to == [comment.owner.email]