示例#1
0
    def test_list_version_1_0(self):
        """List patch comments using API v1.0."""
        patch = create_patch()
        create_comment(submission=patch)

        # check we can't access comments using the old version of the API
        with self.assertRaises(NoReverseMatch):
            self.client.get(self.api_url(patch, version='1.0'))
示例#2
0
    def test_list_version_1_0(self):
        """List cover letter comments using API v1.0."""
        cover = create_cover()
        create_comment(submission=cover)

        # check we can't access comments using the old version of the API
        with self.assertRaises(NoReverseMatch):
            self.client.get(self.api_url(cover, version='1.0'))
 def test_patch_utf8_nbsp(self):
     patch = create_patch(project=self.project,
                          submitter=self.person,
                          content='patch text\n')
     create_comment(submission=patch,
                    submitter=self.person,
                    content=u'comment\nAcked-by:\u00A0 foo')
     response = self.client.get(reverse('patch-mbox', args=[patch.id]))
     self.assertContains(response, u'\u00A0 foo\n')
 def test_patch_response(self):
     patch = create_patch(project=self.project,
                          submitter=self.person,
                          content='comment 1 text\nAcked-by: 1\n')
     create_comment(submission=patch,
                    submitter=self.person,
                    content='comment 2 text\nAcked-by: 2\n')
     response = self.client.get(reverse('patch-mbox', args=[patch.id]))
     self.assertContains(response, 'Acked-by: 1\nAcked-by: 2\n')
示例#5
0
 def test_patch_utf8_nbsp(self):
     patch = create_patch(
         project=self.project,
         submitter=self.person,
         content='patch text\n')
     create_comment(
         submission=patch,
         submitter=self.person,
         content=u'comment\nAcked-by:\u00A0 foo')
     response = self.client.get(reverse('patch-mbox', args=[patch.id]))
     self.assertContains(response, u'\u00A0 foo\n')
示例#6
0
 def test_patch_response(self):
     patch = create_patch(
         project=self.project,
         submitter=self.person,
         content='comment 1 text\nAcked-by: 1\n')
     create_comment(
         submission=patch,
         submitter=self.person,
         content='comment 2 text\nAcked-by: 2\n')
     response = self.client.get(reverse('patch-mbox', args=[patch.id]))
     self.assertContains(response, 'Acked-by: 1\nAcked-by: 2\n')
示例#7
0
    def _test_redirect(self, submission, submission_url, submission_id):
        comment_id = create_comment(submission=submission).id

        requested_url = reverse("comment-redirect", kwargs={"comment_id": comment_id})
        redirect_url = "%s#%d" % (reverse(submission_url, kwargs={submission_id: submission.id}), comment_id)

        response = self.client.get(requested_url)
        self.assertRedirects(response, redirect_url)
示例#8
0
    def test_list(self):
        """List patch comments."""
        patch = create_patch()
        comment = create_comment(submission=patch)

        resp = self.client.get(self.api_url(patch))
        self.assertEqual(status.HTTP_200_OK, resp.status_code)
        self.assertEqual(1, len(resp.data))
        self.assertSerialized(comment, resp.data[0])
示例#9
0
    def test_list(self):
        """List cover letter comments."""
        cover = create_cover()
        comment = create_comment(submission=cover)

        resp = self.client.get(self.api_url(cover))
        self.assertEqual(status.HTTP_200_OK, resp.status_code)
        self.assertEqual(1, len(resp.data))
        self.assertSerialized(comment, resp.data[0])
示例#10
0
 def setUp(self):
     project = create_project()
     self.person = create_person()
     self.patch = create_patch(project=project,
                               submitter=self.person,
                               content='comment 1 text\nAcked-by: 1\n')
     self.comment = create_comment(submission=self.patch,
                                   submitter=self.person,
                                   content='comment 2 text\nAcked-by: 2\n')
示例#11
0
    def _test_redirect(self, submission, submission_url, submission_id):
        comment_id = create_comment(submission=submission).id

        requested_url = reverse('comment-redirect',
                                kwargs={'comment_id': comment_id})
        redirect_url = '%s#%d' % (reverse(
            submission_url, kwargs={submission_id: submission.id}), comment_id)

        response = self.client.get(requested_url)
        self.assertRedirects(response, redirect_url)
示例#12
0
    def test_list(self):
        patch_obj = create_patch()
        resp = self.client.get(self.api_url(patch_obj))
        self.assertEqual(status.HTTP_200_OK, resp.status_code)
        self.assertEqual(0, len(resp.data))

        comment_obj = create_comment(submission=patch_obj)
        resp = self.client.get(self.api_url(patch_obj))
        self.assertEqual(status.HTTP_200_OK, resp.status_code)
        self.assertEqual(1, len(resp.data))
        self.assertSerialized(comment_obj, resp.data[0])

        create_comment(submission=patch_obj)
        resp = self.client.get(self.api_url(patch_obj))
        self.assertEqual(status.HTTP_200_OK, resp.status_code)
        self.assertEqual(2, len(resp.data))

        # check we can't access comments using the old version of the API
        with self.assertRaises(NoReverseMatch):
            self.client.get(self.api_url(patch_obj, version='1.0'))
示例#13
0
    def test_list(self):
        patch_obj = create_patch()
        resp = self.client.get(self.api_url(patch_obj))
        self.assertEqual(status.HTTP_200_OK, resp.status_code)
        self.assertEqual(0, len(resp.data))

        comment_obj = create_comment(submission=patch_obj)
        resp = self.client.get(self.api_url(patch_obj))
        self.assertEqual(status.HTTP_200_OK, resp.status_code)
        self.assertEqual(1, len(resp.data))
        self.assertSerialized(comment_obj, resp.data[0])

        create_comment(submission=patch_obj)
        resp = self.client.get(self.api_url(patch_obj))
        self.assertEqual(status.HTTP_200_OK, resp.status_code)
        self.assertEqual(2, len(resp.data))

        # check we can't access comments using the old version of the API
        with self.assertRaises(NoReverseMatch):
            self.client.get(self.api_url(patch_obj, version='1.0'))
示例#14
0
 def setUp(self):
     project = create_project()
     self.person = create_person()
     self.patch = create_patch(
         project=project,
         submitter=self.person,
         content='comment 1 text\nAcked-by: 1\n')
     self.comment = create_comment(
         submission=self.patch,
         submitter=self.person,
         content='comment 2 text\nAcked-by: 2\n')
示例#15
0
 def create_tag_comment(self, patch, tagtype=None):
     comment = create_comment(
         submission=patch,
         content=self.create_tag(tagtype))
     return comment
示例#16
0
 def create_tag_comment(self, patch, tagtype=None):
     comment = create_comment(submission=patch,
                              content=self.create_tag(tagtype))
     return comment