Beispiel #1
0
    def test_delete_with_existing_comments(self):
        """
        Delete a section with existing comments. This should fail, because sections
        are protected.
        """
        section = MotionCommentSection(name="test_name_ecMCq;ymwuZZ723kD)2k")
        section.save()

        motion = Motion(
            title="test_title_SlqfMw(waso0saWMPqcZ",
            text="test_text_f30skclqS9wWF=xdfaSL",
        )
        motion.save()

        comment = MotionComment(comment="test_comment_dlkMD23m)(D9020m0/Zd",
                                motion=motion,
                                section=section)
        comment.save()

        response = self.client.delete(
            reverse("motioncommentsection-detail", args=[section.pk]))
        self.assertEqual(response.data["args"][0],
                         '"test_title_SlqfMw(waso0saWMPqcZ"')
        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
        self.assertEqual(MotionCommentSection.objects.count(), 1)
Beispiel #2
0
    def test_delete_comment(self):
        comment = MotionComment(
            motion=self.motion,
            section=self.section_read_write,
            comment='test_comment_5CJ"8f23jd3j2,r93keZ',
        )
        comment.save()

        response = self.client.delete(
            reverse("motion-manage-comments", args=[self.motion.pk]),
            {"section_id": self.section_read_write.pk},
        )
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(MotionComment.objects.count(), 0)
Beispiel #3
0
    def test_retrieve_comment_no_read_permission(self):
        comment = MotionComment(
            motion=self.motion,
            section=self.section_no_groups,
            comment="test_comment_fgkj3C7veo3ijWE(j2DJ",
        )
        comment.save()

        response = self.client.get(reverse("motion-detail", args=[self.motion.pk]))
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertTrue("comments" in response.data)
        comments = response.data["comments"]
        self.assertTrue(isinstance(comments, list))
        self.assertEqual(len(comments), 0)
Beispiel #4
0
    def test_retrieve_comment(self):
        comment = MotionComment(
            motion=self.motion,
            section=self.section_read_write,
            comment="test_comment_gwic37Csc&3lf3eo2",
        )
        comment.save()

        response = self.client.get(reverse("motion-detail", args=[self.motion.pk]))
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertTrue("comments" in response.data)
        comments = response.data["comments"]
        self.assertTrue(isinstance(comments, list))
        self.assertEqual(len(comments), 1)
        self.assertEqual(comments[0]["comment"], "test_comment_gwic37Csc&3lf3eo2")
Beispiel #5
0
    def test_delete_comment_no_write_permission(self):
        comment = MotionComment(
            motion=self.motion,
            section=self.section_read,
            comment="test_comment_fej(NF§kfePOF383o8DN",
        )
        comment.save()

        response = self.client.delete(
            reverse("motion-manage-comments", args=[self.motion.pk]),
            {"section_id": self.section_read.pk},
        )
        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
        self.assertEqual(MotionComment.objects.count(), 1)
        comment = MotionComment.objects.get()
        self.assertEqual(comment.comment, "test_comment_fej(NF§kfePOF383o8DN")
Beispiel #6
0
    def test_update_comment_no_write_permission(self):
        comment = MotionComment(
            motion=self.motion,
            section=self.section_read,
            comment="test_comment_jg38dwiej2D832(D§dk)",
        )
        comment.save()

        response = self.client.post(
            reverse("motion-manage-comments", args=[self.motion.pk]),
            {
                "section_id": self.section_read.pk,
                "comment": "test_comment_fk3jrnfwsdg%fj=feijf",
            },
        )
        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
        comment = MotionComment.objects.get()
        self.assertEqual(comment.comment, "test_comment_jg38dwiej2D832(D§dk)")
Beispiel #7
0
    def test_update_comment(self):
        comment = MotionComment(
            motion=self.motion,
            section=self.section_read_write,
            comment="test_comment_fji387fqwdf&ff=)Fe3j",
        )
        comment.save()

        response = self.client.post(
            reverse("motion-manage-comments", args=[self.motion.pk]),
            {
                "section_id": self.section_read_write.pk,
                "comment": "test_comment_fk3jrnfwsdg%fj=feijf",
            },
        )
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        comment = MotionComment.objects.get()
        self.assertEqual(comment.comment, "test_comment_fk3jrnfwsdg%fj=feijf")