コード例 #1
0
ファイル: test_comment.py プロジェクト: wangxi11/patchwork
    def test_list_version_1_0(self):
        """List patch comments using API v1.0."""
        patch = create_patch()
        create_patch_comment(patch=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_utf8_nbsp_tags(self):
        """Test that UTF-8 NBSP characters are correctly handled."""
        patch = create_patch(content='patch text\n')
        create_patch_comment(patch=patch,
                             content=u'comment\nAcked-by:\u00A0 foo')

        mbox = utils.patch_to_mbox(patch)
        self.assertIn(u'\u00A0 foo\n', mbox)
コード例 #3
0
    def test_tags(self):
        """Test that tags are taken from a patch comment."""
        patch = create_patch(content='comment 1 text\nAcked-by: 1\n')
        create_patch_comment(patch=patch,
                             content='comment 2 text\nAcked-by: 2\n')

        mbox = utils.patch_to_mbox(patch)
        self.assertIn('Acked-by: 1\nAcked-by: 2\n', mbox)
コード例 #4
0
    def test_list_version_1_1(self):
        """List patch comments using API v1.1."""
        create_patch_comment(patch=self.patch)

        resp = self.client.get(self.api_url(self.patch, version='1.1'))
        self.assertEqual(status.HTTP_200_OK, resp.status_code)
        self.assertEqual(1, len(resp.data))
        self.assertNotIn('list_archive_url', resp.data[0])
        self.assertNotIn('addressed', resp.data[0])
コード例 #5
0
    def test_find_patch_for_comment__indirect_reply(self):
        """Test behavior when we only have a reference to a comment."""
        msgid = make_msgid()
        project = create_project()
        patch = create_patch(project=project)
        create_patch_comment(patch=patch, msgid=msgid)

        result = parser.find_patch_for_comment(project, [msgid])

        self.assertEqual(patch, result)
コード例 #6
0
ファイル: test_mboxviews.py プロジェクト: wangxi11/patchwork
 def test_patch_utf8_nbsp(self):
     patch = create_patch(project=self.project,
                          submitter=self.person,
                          content='patch text\n')
     create_patch_comment(patch=patch,
                          submitter=self.person,
                          content=u'comment\nAcked-by:\u00A0 foo')
     response = self.client.get(
         reverse('patch-mbox',
                 args=[self.project.linkname, patch.url_msgid]))
     self.assertContains(response, u'\u00A0 foo\n')
コード例 #7
0
ファイル: test_mboxviews.py プロジェクト: wangxi11/patchwork
 def test_patch_response(self):
     patch = create_patch(project=self.project,
                          submitter=self.person,
                          content='comment 1 text\nAcked-by: 1\n')
     create_patch_comment(patch=patch,
                          submitter=self.person,
                          content='comment 2 text\nAcked-by: 2\n')
     response = self.client.get(
         reverse('patch-mbox',
                 args=[self.project.linkname, patch.url_msgid]))
     self.assertContains(response, 'Acked-by: 1\nAcked-by: 2\n')
コード例 #8
0
    def test_detail_version_1_0(self):
        """Show a patch comment using API v1.0."""
        comment = create_patch_comment(patch=self.patch)

        with self.assertRaises(NoReverseMatch):
            self.client.get(
                self.api_url(self.patch, version='1.0', item=comment))
コード例 #9
0
    def test_detail(self):
        """Show a patch comment."""
        comment = create_patch_comment(patch=self.patch)

        resp = self.client.get(self.api_url(self.patch, item=comment))
        self.assertEqual(status.HTTP_200_OK, resp.status_code)
        self.assertSerialized(comment, resp.data)
コード例 #10
0
ファイル: test_comment.py プロジェクト: wangxi11/patchwork
    def test_list(self):
        """List patch comments."""
        patch = create_patch()
        comment = create_patch_comment(patch=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])
コード例 #11
0
    def test_list(self):
        """List patch comments."""
        comment = create_patch_comment(patch=self.patch)

        resp = self.client.get(self.api_url(self.patch))
        self.assertEqual(status.HTTP_200_OK, resp.status_code)
        self.assertEqual(1, len(resp.data))
        self.assertSerialized(comment, resp.data[0])
        self.assertIn('list_archive_url', resp.data[0])
        self.assertIn('addressed', resp.data[0])
コード例 #12
0
 def test_detail_invalid_patch(self):
     """Ensure we handle non-existent patches."""
     comment = create_patch_comment()
     resp = self.client.get(
         reverse('api-patch-comment-detail',
                 kwargs={
                     'patch_id': '99999',
                     'comment_id': comment.id
                 }), )
     self.assertEqual(status.HTTP_404_NOT_FOUND, resp.status_code)
コード例 #13
0
    def _test_update(self, person, **kwargs):
        submitter = kwargs.get('submitter', person)
        patch = kwargs.get('patch', self.patch)
        comment = create_patch_comment(submitter=submitter, patch=patch)

        if kwargs.get('authenticate', True):
            self.client.force_authenticate(user=person.user)
        return self.client.patch(self.api_url(patch, item=comment),
                                 {'addressed': kwargs.get('addressed', True)},
                                 validate_request=kwargs.get(
                                     'validate_request', True))
コード例 #14
0
 def test_patch_comment_created(self):
     """Validate 'patch-comment-created' events."""
     comment = utils.create_patch_comment()
     events = _get_events(patch_comment=comment)
     self.assertEqual(events.count(), 1)
     self.assertEqual(
         events[0].category,
         Event.CATEGORY_PATCH_COMMENT_CREATED,
     )
     self.assertEqual(events[0].project, comment.patch.project)
     self.assertEventFields(events[0])
コード例 #15
0
    def test_create_delete(self):
        """Ensure creates and deletes aren't allowed"""
        comment = create_patch_comment(patch=self.patch)
        self.user.is_superuser = True
        self.user.save()
        self.client.force_authenticate(user=self.user)

        resp = self.client.post(self.api_url(self.patch, item=comment))
        self.assertEqual(status.HTTP_405_METHOD_NOT_ALLOWED, resp.status_code)

        resp = self.client.delete(self.api_url(self.patch, item=comment))
        self.assertEqual(status.HTTP_405_METHOD_NOT_ALLOWED, resp.status_code)
コード例 #16
0
ファイル: test_mboxviews.py プロジェクト: wangxi11/patchwork
 def setUp(self):
     self.project = create_project()
     self.person = create_person()
     self.patch = create_patch(
         project=self.project,
         submitter=self.person,
         diff='',
         content='comment 1 text\nAcked-by: 1\n---\nupdate\n')
     self.comment = create_patch_comment(
         patch=self.patch,
         submitter=self.person,
         content='comment 2 text\nAcked-by: 2\n')
コード例 #17
0
    def test_comment_redirect(self):
        patch = create_patch()
        comment_id = create_patch_comment(patch=patch).id

        requested_url = reverse('comment-redirect',
                                kwargs={'comment_id': comment_id})
        redirect_url = '%s#%d' % (
            reverse('patch-detail',
                    kwargs={'project_id': patch.project.linkname,
                            'msgid': patch.url_msgid}),
            comment_id)

        response = self.client.get(requested_url)
        self.assertRedirects(response, redirect_url)
コード例 #18
0
    def test_multiple_tags(self):
        """Test that the mbox view appends tags correct.

        Ensure the tags are extracted from a patch comment, and placed before
        an '---' update line.
        """
        self.project = create_project()
        self.person = create_person()
        self.patch = create_patch(
            project=self.project,
            submitter=self.person,
            diff='',
            content='comment 1 text\nAcked-by: 1\n---\nupdate\n')
        self.comment = create_patch_comment(
            patch=self.patch,
            submitter=self.person,
            content='comment 2 text\nAcked-by: 2\n')

        mbox = utils.patch_to_mbox(self.patch)
        self.assertIn('Acked-by: 1\nAcked-by: 2\n', mbox)
コード例 #19
0
 def create_tag_comment(self, patch, tagtype=None):
     comment = create_patch_comment(patch=patch,
                                    content=self.create_tag(tagtype))
     return comment