Ejemplo n.º 1
0
    def test_create(self):
        self.log_user()
        rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc'
        text = u'CommentOnRevision'

        params = {'text': text}
        response = self.app.post(url(controller='changeset', action='comment',
                                     repo_name=HG_REPO, revision=rev),
                                     params=params)
        # Test response...
        self.assertEqual(response.status, '302 Found')
        response.follow()

        response = self.app.get(url(controller='changeset', action='index',
                                repo_name=HG_REPO, revision=rev))
        # test DB
        self.assertEqual(ChangesetComment.query().count(), 1)
        response.mustcontain(
            '''<div class="comments-number">'''
            ''' 1 comment (0 inline, 1 general)'''
        )

        self.assertEqual(Notification.query().count(), 1)
        self.assertEqual(ChangesetComment.query().count(), 1)

        notification = Notification.query().all()[0]

        ID = ChangesetComment.query().first().comment_id
        self.assertEqual(notification.type_,
                         Notification.TYPE_CHANGESET_COMMENT)
        sbj = (u'/vcs_test_hg/changeset/'
               '27cd5cce30c96924232dffcd24178a07ffeb5dfc#comment-%s' % ID)
        print "%s vs %s" % (sbj, notification.subject)
        self.assertTrue(sbj in notification.subject)
Ejemplo n.º 2
0
    def test_create(self):
        self.log_user()
        rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc'
        text = u'CommentOnRevision'

        params = {'text': text, '_authentication_token': self.authentication_token()}
        response = self.app.post(url(controller='changeset', action='comment',
                                     repo_name=HG_REPO, revision=rev),
                                     params=params, extra_environ={'HTTP_X_PARTIAL_XHR': '1'})
        # Test response...
        self.assertEqual(response.status, '200 OK')

        response = self.app.get(url(controller='changeset', action='index',
                                repo_name=HG_REPO, revision=rev))
        # test DB
        self.assertEqual(ChangesetComment.query().count(), 1)
        response.mustcontain(
            '''<div class="comments-number">'''
            ''' 1 comment (0 inline, 1 general)'''
        )

        self.assertEqual(Notification.query().count(), 1)
        self.assertEqual(ChangesetComment.query().count(), 1)

        notification = Notification.query().all()[0]

        ID = ChangesetComment.query().first().comment_id
        self.assertEqual(notification.type_,
                         Notification.TYPE_CHANGESET_COMMENT)
        sbj = (u'/%s/changeset/'
               '27cd5cce30c96924232dffcd24178a07ffeb5dfc#comment-%s' % (HG_REPO, ID))
        print "%s vs %s" % (sbj, notification.subject)
        self.assertTrue(sbj in notification.subject)
Ejemplo n.º 3
0
    def test_delete(self):
        self.log_user()
        rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc'
        text = u'CommentOnRevision'

        params = {'text': text}
        response = self.app.post(url(controller='changeset', action='comment',
                                     repo_name=HG_REPO, revision=rev),
                                     params=params)

        comments = ChangesetComment.query().all()
        self.assertEqual(len(comments), 1)
        comment_id = comments[0].comment_id

        self.app.delete(url(controller='changeset',
                                    action='delete_comment',
                                    repo_name=HG_REPO,
                                    comment_id=comment_id))

        comments = ChangesetComment.query().all()
        self.assertEqual(len(comments), 0)

        response = self.app.get(url(controller='changeset', action='index',
                                repo_name=HG_REPO, revision=rev))
        response.mustcontain(
            '''<div class="comments-number">'''
            ''' 0 comments (0 inline, 0 general)'''
        )
Ejemplo n.º 4
0
    def test_delete(self):
        self.log_user()
        rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc'
        text = u'CommentOnRevision'

        params = {'text': text, '_authentication_token': self.authentication_token()}
        response = self.app.post(url(controller='changeset', action='comment',
                                     repo_name=HG_REPO, revision=rev),
                                     params=params, extra_environ={'HTTP_X_PARTIAL_XHR': '1'})

        comments = ChangesetComment.query().all()
        self.assertEqual(len(comments), 1)
        comment_id = comments[0].comment_id

        self.app.post(url(controller='changeset',
                                    action='delete_comment',
                                    repo_name=HG_REPO,
                                    comment_id=comment_id),
            params={'_method': 'delete', '_authentication_token': self.authentication_token()})

        comments = ChangesetComment.query().all()
        self.assertEqual(len(comments), 0)

        response = self.app.get(url(controller='changeset', action='index',
                                repo_name=HG_REPO, revision=rev))
        response.mustcontain(
            '''<div class="comments-number">'''
            ''' 0 comments (0 inline, 0 general)'''
        )
    def test_create_inline(self):
        self.log_user()
        rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc'
        text = u'CommentOnRevision'
        f_path = 'vcs/web/simplevcs/views/repository.py'
        line = 'n1'

        params = {
            'text': text,
            'f_path': f_path,
            'line': line,
            '_authentication_token': self.authentication_token()
        }
        response = self.app.post(url(controller='changeset',
                                     action='comment',
                                     repo_name=HG_REPO,
                                     revision=rev),
                                 params=params,
                                 extra_environ={'HTTP_X_PARTIAL_XHR': '1'})
        # Test response...
        assert response.status == '200 OK'

        response = self.app.get(
            url(controller='changeset',
                action='index',
                repo_name=HG_REPO,
                revision=rev))
        #test DB
        assert ChangesetComment.query().count() == 1
        response.mustcontain('''<div class="comments-number">'''
                             ''' 1 comment (1 inline, 0 general)''')
        response.mustcontain(
            '''<div class="comments-list-chunk" '''
            '''data-f_path="vcs/web/simplevcs/views/repository.py" '''
            '''data-line_no="n1" data-target-id="vcswebsimplevcsviewsrepositorypy_n1">'''
        )

        assert Notification.query().count() == 1
        assert ChangesetComment.query().count() == 1

        notification = Notification.query().all()[0]
        ID = ChangesetComment.query().first().comment_id
        assert notification.type_ == Notification.TYPE_CHANGESET_COMMENT
        sbj = (u'/%s/changeset/'
               '27cd5cce30c96924232dffcd24178a07ffeb5dfc#comment-%s' %
               (HG_REPO, ID))
        print "%s vs %s" % (sbj, notification.subject)
        assert sbj in notification.subject
    def test_create_with_mention(self):
        self.log_user()

        rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc'
        text = u'@test_regular check CommentOnRevision'

        params = {'text': text, '_authentication_token': self.authentication_token()}
        response = self.app.post(url(controller='changeset', action='comment',
                                     repo_name=HG_REPO, revision=rev),
                                     params=params)
        # Test response...
        self.assertEqual(response.status, '302 Found')
        response.follow()

        response = self.app.get(url(controller='changeset', action='index',
                                repo_name=HG_REPO, revision=rev))
        # test DB
        self.assertEqual(ChangesetComment.query().count(), 1)
        response.mustcontain(
            '''<div class="comments-number">'''
            ''' 1 comment (0 inline, 1 general)'''
        )

        self.assertEqual(Notification.query().count(), 2)
        users = [x.user.username for x in UserNotification.query().all()]

        # test_regular gets notification by @mention
        self.assertEqual(sorted(users), [u'test_admin', u'test_regular'])
Ejemplo n.º 7
0
    def test_create_with_mention(self):
        self.log_user()

        rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc'
        text = u'@test_regular check CommentOnRevision'

        params = {'text':text}
        response = self.app.post(url(controller='changeset', action='comment',
                                     repo_name=HG_REPO, revision=rev),
                                     params=params)
        # Test response...
        self.assertEqual(response.status, '302 Found')
        response.follow()

        response = self.app.get(url(controller='changeset', action='index',
                                repo_name=HG_REPO, revision=rev))
        # test DB
        self.assertEqual(ChangesetComment.query().count(), 1)
        response.mustcontain(
            '''<div class="comments-number">'''
            ''' 1 comment (0 inline, 1 general)'''
        )

        self.assertEqual(Notification.query().count(), 2)
        users = [x.user.username for x in UserNotification.query().all()]

        # test_regular gets notification by @mention
        self.assertEqual(sorted(users), [u'test_admin', u'test_regular'])
    def test_create_with_mention(self):
        self.log_user()
        pr_id = self._create_pr()

        text = '@%s check CommentOnRevision' % base.TEST_USER_REGULAR_LOGIN
        params = {
            'text': text,
            '_session_csrf_secret_token': self.session_csrf_secret_token()
        }
        response = self.app.post(base.url(controller='pullrequests',
                                          action='comment',
                                          repo_name=base.HG_REPO,
                                          pull_request_id=pr_id),
                                 params=params,
                                 extra_environ={'HTTP_X_PARTIAL_XHR': '1'})
        # Test response...
        assert response.status == '200 OK'

        response = self.app.get(
            base.url(controller='pullrequests',
                     action='show',
                     repo_name=base.HG_REPO,
                     pull_request_id=pr_id,
                     extra=''))
        response.mustcontain('''<div class="comments-number">'''
                             ''' 2 comments (0 inline, 2 general)''')
        response.mustcontain('<b>@%s</b> check CommentOnRevision' %
                             base.TEST_USER_REGULAR_LOGIN)

        # test DB
        assert ChangesetComment.query().count() == 2
    def test_create_status_change(self):
        self.log_user()
        rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc'
        text = 'general comment on changeset'

        params = {
            'text': text,
            'changeset_status': 'rejected',
            '_session_csrf_secret_token': self.session_csrf_secret_token()
        }
        response = self.app.post(base.url(controller='changeset',
                                          action='comment',
                                          repo_name=base.HG_REPO,
                                          revision=rev),
                                 params=params,
                                 extra_environ={'HTTP_X_PARTIAL_XHR': '1'})
        # Test response...
        assert response.status == '200 OK'

        response = self.app.get(
            base.url(controller='changeset',
                     action='index',
                     repo_name=base.HG_REPO,
                     revision=rev))
        response.mustcontain('''<div class="comments-number">'''
                             ''' 1 comment (0 inline, 1 general)''')
        response.mustcontain(text)

        # test DB
        assert ChangesetComment.query().count() == 1

        # check status
        status = ChangesetStatusModel().get_status(repo=base.HG_REPO,
                                                   revision=rev)
        assert status == 'rejected'
    def test_create_with_mention(self):
        self.log_user()

        rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc'
        text = '@%s check CommentOnRevision' % base.TEST_USER_REGULAR_LOGIN

        params = {
            'text': text,
            '_session_csrf_secret_token': self.session_csrf_secret_token()
        }
        response = self.app.post(base.url(controller='changeset',
                                          action='comment',
                                          repo_name=base.HG_REPO,
                                          revision=rev),
                                 params=params,
                                 extra_environ={'HTTP_X_PARTIAL_XHR': '1'})
        # Test response...
        assert response.status == '200 OK'

        response = self.app.get(
            base.url(controller='changeset',
                     action='index',
                     repo_name=base.HG_REPO,
                     revision=rev))
        response.mustcontain('''<div class="comments-number">'''
                             ''' 1 comment (0 inline, 1 general)''')
        response.mustcontain('<b>@%s</b> check CommentOnRevision' %
                             base.TEST_USER_REGULAR_LOGIN)

        # test DB
        assert ChangesetComment.query().count() == 1
Ejemplo n.º 11
0
    def test_create_with_mention(self):
        self.log_user()

        rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc'
        text = u'@%s check CommentOnRevision' % TEST_USER_REGULAR_LOGIN

        params = {'text': text, '_authentication_token': self.authentication_token()}
        response = self.app.post(url(controller='changeset', action='comment',
                                     repo_name=HG_REPO, revision=rev),
                                     params=params, extra_environ={'HTTP_X_PARTIAL_XHR': '1'})
        # Test response...
        self.assertEqual(response.status, '200 OK')

        response = self.app.get(url(controller='changeset', action='index',
                                repo_name=HG_REPO, revision=rev))
        # test DB
        self.assertEqual(ChangesetComment.query().count(), 1)
        response.mustcontain(
            '''<div class="comments-number">'''
            ''' 1 comment (0 inline, 1 general)'''
        )

        self.assertEqual(Notification.query().count(), 2)
        users = [x.user.username for x in UserNotification.query().all()]

        # test_regular gets notification by @mention
        self.assertEqual(sorted(users), [TEST_USER_ADMIN_LOGIN, TEST_USER_REGULAR_LOGIN])
    def test_create(self):
        self.log_user()
        pr_id = self._create_pr()

        text = 'general comment on pullrequest'
        params = {
            'text': text,
            '_session_csrf_secret_token': self.session_csrf_secret_token()
        }
        response = self.app.post(base.url(controller='pullrequests',
                                          action='comment',
                                          repo_name=base.HG_REPO,
                                          pull_request_id=pr_id),
                                 params=params,
                                 extra_environ={'HTTP_X_PARTIAL_XHR': '1'})
        # Test response...
        assert response.status == '200 OK'

        response = self.app.get(
            base.url(controller='pullrequests',
                     action='show',
                     repo_name=base.HG_REPO,
                     pull_request_id=pr_id,
                     extra=''))
        # PRs currently always have an initial 'Under Review' status change
        # that counts as a general comment, hence '2' in the test below. That
        # could be counted as a misfeature, to be reworked later.
        response.mustcontain('''<div class="comments-number">'''
                             ''' 2 comments (0 inline, 2 general)''')
        response.mustcontain(text)

        # test DB
        assert ChangesetComment.query().count() == 2
Ejemplo n.º 13
0
    def setUp(self):
        for x in ChangesetComment.query().all():
            Session().delete(x)
        Session().commit()

        for x in Notification.query().all():
            Session().delete(x)
        Session().commit()
    def setUp(self):
        for x in ChangesetComment.query().all():
            Session().delete(x)
        Session().commit()

        for x in Notification.query().all():
            Session().delete(x)
        Session().commit()
    def test_create_inline(self):
        self.log_user()
        rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc'
        text = u'CommentOnRevision'
        f_path = 'vcs/web/simplevcs/views/repository.py'
        line = 'n1'

        params = {'text': text, 'f_path': f_path, 'line': line, '_authentication_token': self.authentication_token()}
        response = self.app.post(url(controller='changeset', action='comment',
                                     repo_name=HG_REPO, revision=rev),
                                     params=params)
        # Test response...
        self.assertEqual(response.status, '302 Found')
        response.follow()

        response = self.app.get(url(controller='changeset', action='index',
                                repo_name=HG_REPO, revision=rev))
        #test DB
        self.assertEqual(ChangesetComment.query().count(), 1)
        response.mustcontain(
            '''<div class="comments-number">'''
            ''' 1 comment (1 inline, 0 general)'''
        )
        response.mustcontain(
            '''<div style="display:none" class="inline-comment-placeholder" '''
            '''path="vcs/web/simplevcs/views/repository.py" '''
            '''target_id="vcswebsimplevcsviewsrepositorypy">'''
        )

        self.assertEqual(Notification.query().count(), 1)
        self.assertEqual(ChangesetComment.query().count(), 1)

        notification = Notification.query().all()[0]
        ID = ChangesetComment.query().first().comment_id
        self.assertEqual(notification.type_,
                         Notification.TYPE_CHANGESET_COMMENT)
        sbj = (u'/vcs_test_hg/changeset/'
               '27cd5cce30c96924232dffcd24178a07ffeb5dfc#comment-%s' % ID)
        print "%s vs %s" % (sbj, notification.subject)
        self.assertTrue(sbj in notification.subject)
Ejemplo n.º 16
0
    def test_create_inline(self):
        self.log_user()
        rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc'
        text = u'CommentOnRevision'
        f_path = 'vcs/web/simplevcs/views/repository.py'
        line = 'n1'

        params = {'text': text, 'f_path': f_path, 'line': line}
        response = self.app.post(url(controller='changeset', action='comment',
                                     repo_name=HG_REPO, revision=rev),
                                     params=params)
        # Test response...
        self.assertEqual(response.status, '302 Found')
        response.follow()

        response = self.app.get(url(controller='changeset', action='index',
                                repo_name=HG_REPO, revision=rev))
        #test DB
        self.assertEqual(ChangesetComment.query().count(), 1)
        response.mustcontain(
            '''<div class="comments-number">'''
            ''' 1 comment (1 inline, 0 general)'''
        )
        response.mustcontain(
            '''<div style="display:none" class="inline-comment-placeholder" '''
            '''path="vcs/web/simplevcs/views/repository.py" '''
            '''target_id="vcswebsimplevcsviewsrepositorypy">'''
        )

        self.assertEqual(Notification.query().count(), 1)
        self.assertEqual(ChangesetComment.query().count(), 1)

        notification = Notification.query().all()[0]
        ID = ChangesetComment.query().first().comment_id
        self.assertEqual(notification.type_,
                         Notification.TYPE_CHANGESET_COMMENT)
        sbj = (u'/vcs_test_hg/changeset/'
               '27cd5cce30c96924232dffcd24178a07ffeb5dfc#comment-%s' % ID)
        print "%s vs %s" % (sbj, notification.subject)
        self.assertTrue(sbj in notification.subject)
    def test_create(self):
        self.log_user()
        rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc'
        text = u'CommentOnRevision'

        params = {
            'text': text,
            '_authentication_token': self.authentication_token()
        }
        response = self.app.post(url(controller='changeset',
                                     action='comment',
                                     repo_name=HG_REPO,
                                     revision=rev),
                                 params=params,
                                 extra_environ={'HTTP_X_PARTIAL_XHR': '1'})
        # Test response...
        assert response.status == '200 OK'

        response = self.app.get(
            url(controller='changeset',
                action='index',
                repo_name=HG_REPO,
                revision=rev))
        # test DB
        assert ChangesetComment.query().count() == 1
        response.mustcontain('''<div class="comments-number">'''
                             ''' 1 comment (0 inline, 1 general)''')

        assert Notification.query().count() == 1
        assert ChangesetComment.query().count() == 1

        notification = Notification.query().all()[0]

        ID = ChangesetComment.query().first().comment_id
        assert notification.type_ == Notification.TYPE_CHANGESET_COMMENT
        sbj = (u'/%s/changeset/'
               '27cd5cce30c96924232dffcd24178a07ffeb5dfc#comment-%s' %
               (HG_REPO, ID))
        print "%s vs %s" % (sbj, notification.subject)
        assert sbj in notification.subject
    def test_delete(self):
        self.log_user()
        pr_id = self._create_pr()

        text = 'general comment on changeset to be deleted'
        params = {
            'text': text,
            '_session_csrf_secret_token': self.session_csrf_secret_token()
        }
        response = self.app.post(base.url(controller='pullrequests',
                                          action='comment',
                                          repo_name=base.HG_REPO,
                                          pull_request_id=pr_id),
                                 params=params,
                                 extra_environ={'HTTP_X_PARTIAL_XHR': '1'})

        comments = ChangesetComment.query().all()
        assert len(comments) == 2
        comment_id = comments[-1].comment_id

        self.app.post(base.url("pullrequest_comment_delete",
                               repo_name=base.HG_REPO,
                               comment_id=comment_id),
                      params={
                          '_session_csrf_secret_token':
                          self.session_csrf_secret_token()
                      })

        comments = ChangesetComment.query().all()
        assert len(comments) == 1

        response = self.app.get(
            base.url(controller='pullrequests',
                     action='show',
                     repo_name=base.HG_REPO,
                     pull_request_id=pr_id,
                     extra=''))
        response.mustcontain('''<div class="comments-number">'''
                             ''' 1 comment (0 inline, 1 general)''')
        response.mustcontain(no=text)
    def test_delete(self):
        self.log_user()
        rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc'
        text = 'general comment on changeset to be deleted'

        params = {
            'text': text,
            '_session_csrf_secret_token': self.session_csrf_secret_token()
        }
        response = self.app.post(base.url(controller='changeset',
                                          action='comment',
                                          repo_name=base.HG_REPO,
                                          revision=rev),
                                 params=params,
                                 extra_environ={'HTTP_X_PARTIAL_XHR': '1'})

        comments = ChangesetComment.query().all()
        assert len(comments) == 1
        comment_id = comments[0].comment_id

        self.app.post(base.url("changeset_comment_delete",
                               repo_name=base.HG_REPO,
                               comment_id=comment_id),
                      params={
                          '_session_csrf_secret_token':
                          self.session_csrf_secret_token()
                      })

        comments = ChangesetComment.query().all()
        assert len(comments) == 0

        response = self.app.get(
            base.url(controller='changeset',
                     action='index',
                     repo_name=base.HG_REPO,
                     revision=rev))
        response.mustcontain('''<div class="comments-number">'''
                             ''' 0 comments (0 inline, 0 general)''')
        response.mustcontain(no=text)
Ejemplo n.º 20
0
    def test_create_inline(self):
        self.log_user()
        rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc'
        text = u'CommentOnRevision'
        f_path = 'vcs/web/simplevcs/views/repository.py'
        line = 'n1'

        params = {'text': text, 'f_path': f_path, 'line': line, '_authentication_token': self.authentication_token()}
        response = self.app.post(url(controller='changeset', action='comment',
                                     repo_name=HG_REPO, revision=rev),
                                     params=params, extra_environ={'HTTP_X_PARTIAL_XHR': '1'})
        # Test response...
        self.assertEqual(response.status, '200 OK')

        response = self.app.get(url(controller='changeset', action='index',
                                repo_name=HG_REPO, revision=rev))
        #test DB
        self.assertEqual(ChangesetComment.query().count(), 1)
        response.mustcontain(
            '''<div class="comments-number">'''
            ''' 1 comment (1 inline, 0 general)'''
        )
        response.mustcontain(
            '''<div class="comments-list-chunk" '''
            '''data-f_path="vcs/web/simplevcs/views/repository.py" '''
            '''data-line_no="n1" data-target-id="vcswebsimplevcsviewsrepositorypy_n1">'''
        )

        self.assertEqual(Notification.query().count(), 1)
        self.assertEqual(ChangesetComment.query().count(), 1)

        notification = Notification.query().all()[0]
        ID = ChangesetComment.query().first().comment_id
        self.assertEqual(notification.type_,
                         Notification.TYPE_CHANGESET_COMMENT)
        sbj = (u'/%s/changeset/'
               '27cd5cce30c96924232dffcd24178a07ffeb5dfc#comment-%s' % (HG_REPO, ID))
        print "%s vs %s" % (sbj, notification.subject)
        self.assertTrue(sbj in notification.subject)
Ejemplo n.º 21
0
    def get_comments(self, repo_id, revision=None, pull_request=None):
        """
        Gets main comments based on revision or pull_request_id

        :param repo_id:
        :param revision:
        :param pull_request:
        """

        q = ChangesetComment.query()\
                .filter(ChangesetComment.repo_id == repo_id)\
                .filter(ChangesetComment.line_no == None)\
                .filter(ChangesetComment.f_path == None)
        if revision:
            q = q.filter(ChangesetComment.revision == revision)
        elif pull_request:
            pull_request = self.__get_pull_request(pull_request)
            q = q.filter(ChangesetComment.pull_request == pull_request)
        else:
            raise Exception('Please specify revision or pull_request')
        q = q.order_by(ChangesetComment.created_on)
        return q.all()
Ejemplo n.º 22
0
    def get_comments(self, repo_id, revision=None, pull_request=None):
        """
        Gets main comments based on revision or pull_request_id

        :param repo_id:
        :param revision:
        :param pull_request:
        """

        q = ChangesetComment.query()\
                .filter(ChangesetComment.repo_id == repo_id)\
                .filter(ChangesetComment.line_no == None)\
                .filter(ChangesetComment.f_path == None)
        if revision:
            q = q.filter(ChangesetComment.revision == revision)
        elif pull_request:
            pull_request = self.__get_pull_request(pull_request)
            q = q.filter(ChangesetComment.pull_request == pull_request)
        else:
            raise Exception('Please specify revision or pull_request')
        q = q.order_by(ChangesetComment.created_on)
        return q.all()
    def test_create_inline(self):
        self.log_user()
        pr_id = self._create_pr()

        text = 'inline comment on changeset'
        f_path = 'vcs/web/simplevcs/views/repository.py'
        line = 'n1'
        params = {
            'text': text,
            'f_path': f_path,
            'line': line,
            '_session_csrf_secret_token': self.session_csrf_secret_token()
        }
        response = self.app.post(base.url(controller='pullrequests',
                                          action='comment',
                                          repo_name=base.HG_REPO,
                                          pull_request_id=pr_id),
                                 params=params,
                                 extra_environ={'HTTP_X_PARTIAL_XHR': '1'})
        # Test response...
        assert response.status == '200 OK'

        response = self.app.get(
            base.url(controller='pullrequests',
                     action='show',
                     repo_name=base.HG_REPO,
                     pull_request_id=pr_id,
                     extra=''))
        response.mustcontain('''<div class="comments-number">'''
                             ''' 2 comments (1 inline, 1 general)''')
        response.mustcontain(
            '''<div class="comments-list-chunk" '''
            '''data-f_path="vcs/web/simplevcs/views/repository.py" '''
            '''data-line_no="n1" data-target-id="vcswebsimplevcsviewsrepositorypy_n1">'''
        )
        response.mustcontain(text)

        # test DB
        assert ChangesetComment.query().count() == 2
    def test_create_inline(self):
        self.log_user()
        rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc'
        text = 'inline comment on changeset'
        f_path = 'vcs/web/simplevcs/views/repository.py'
        line = 'n1'

        params = {
            'text': text,
            'f_path': f_path,
            'line': line,
            '_session_csrf_secret_token': self.session_csrf_secret_token()
        }
        response = self.app.post(base.url(controller='changeset',
                                          action='comment',
                                          repo_name=base.HG_REPO,
                                          revision=rev),
                                 params=params,
                                 extra_environ={'HTTP_X_PARTIAL_XHR': '1'})
        # Test response...
        assert response.status == '200 OK'

        response = self.app.get(
            base.url(controller='changeset',
                     action='index',
                     repo_name=base.HG_REPO,
                     revision=rev))
        response.mustcontain('''<div class="comments-number">'''
                             ''' 1 comment (1 inline, 0 general)''')
        response.mustcontain(
            '''<div class="comments-list-chunk" '''
            '''data-f_path="vcs/web/simplevcs/views/repository.py" '''
            '''data-line_no="n1" data-target-id="vcswebsimplevcsviewsrepositorypy_n1">'''
        )
        response.mustcontain(text)

        # test DB
        assert ChangesetComment.query().count() == 1
    def test_create_with_mention(self):
        self.log_user()

        rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc'
        text = u'@%s check CommentOnRevision' % TEST_USER_REGULAR_LOGIN

        params = {
            'text': text,
            '_authentication_token': self.authentication_token()
        }
        response = self.app.post(url(controller='changeset',
                                     action='comment',
                                     repo_name=HG_REPO,
                                     revision=rev),
                                 params=params,
                                 extra_environ={'HTTP_X_PARTIAL_XHR': '1'})
        # Test response...
        assert response.status == '200 OK'

        response = self.app.get(
            url(controller='changeset',
                action='index',
                repo_name=HG_REPO,
                revision=rev))
        # test DB
        assert ChangesetComment.query().count() == 1
        response.mustcontain('''<div class="comments-number">'''
                             ''' 1 comment (0 inline, 1 general)''')

        assert Notification.query().count() == 2
        users = [x.user.username for x in UserNotification.query().all()]

        # test_regular gets notification by @mention
        assert sorted(users) == [
            TEST_USER_ADMIN_LOGIN, TEST_USER_REGULAR_LOGIN
        ]
    def setup_method(self, method):
        for x in ChangesetComment.query().all():
            Session().delete(x)
        Session().commit()

        self.remove_all_notifications()
    def setup_method(self, method):
        for x in ChangesetComment.query().all():
            Session().delete(x)
        Session().commit()

        self.remove_all_notifications()
 def setup_method(self, method):
     for x in ChangesetComment.query().all():
         Session().delete(x)
     Session().commit()
Ejemplo n.º 29
0
    def setUp(self):
        for x in ChangesetComment.query().all():
            Session().delete(x)
        Session().commit()

        remove_all_notifications()