diff --git a/kallithea/tests/functional/test_changeset_comments.py b/kallithea/tests/functional/test_changeset_comments.py --- a/kallithea/tests/functional/test_changeset_comments.py +++ b/kallithea/tests/functional/test_changeset_comments.py @@ -1,3 +1,5 @@ +import re + from kallithea.tests.base import * from kallithea.model.db import ChangesetComment, Notification, \ UserNotification @@ -145,3 +147,160 @@ class TestChangeSetCommentsController(Te ''' 0 comments (0 inline, 0 general)''' ) response.mustcontain(no=text) + + +class TestPullrequestsCommentsController(TestController): + + def setup_method(self, method): + for x in ChangesetComment.query().all(): + Session().delete(x) + Session().commit() + + self.remove_all_notifications() + + def _create_pr(self): + response = self.app.post(url(controller='pullrequests', action='create', + repo_name=HG_REPO), + {'org_repo': HG_REPO, + 'org_ref': 'branch:stable:4f7e2131323e0749a740c0a56ab68ae9269c562a', + 'other_repo': HG_REPO, + 'other_ref': 'branch:default:96507bd11ecc815ebc6270fdf6db110928c09c1e', + 'pullrequest_title': 'title', + 'pullrequest_desc': 'description', + '_authentication_token': self.authentication_token(), + }, + status=302) + pr_id = int(re.search('/pull-request/(\d+)/', response.location).group(1)) + return pr_id + + def test_create(self): + self.log_user() + pr_id = self._create_pr() + + text = u'general comment on pullrequest' + params = {'text': text, '_authentication_token': self.authentication_token()} + response = self.app.post(url(controller='pullrequests', action='comment', + repo_name=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(url(controller='pullrequests', action='show', + repo_name=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( + '''