changeset 6265:ec2e9123c683

tests: add a bit of test coverage for pull request update and iterations
author Mads Kiilerich <madski@unity3d.com>
date Mon, 24 Oct 2016 15:18:51 +0200
parents 93a56b5264d3
children 6744baed1e96
files kallithea/tests/functional/test_pullrequests.py
diffstat 1 files changed, 56 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/tests/functional/test_pullrequests.py	Mon Oct 24 15:18:51 2016 +0200
+++ b/kallithea/tests/functional/test_pullrequests.py	Mon Oct 24 15:18:51 2016 +0200
@@ -33,6 +33,62 @@
         assert response.status == '200 OK'
         response.mustcontain('This pull request has already been merged to default.')
 
+    def test_update_reviewers(self):
+        self.log_user()
+        regular_user = User.get_by_username(TEST_USER_REGULAR_LOGIN)
+        regular_user2 = User.get_by_username(TEST_USER_REGULAR2_LOGIN)
+
+        # create initial PR
+        response = self.app.post(url(controller='pullrequests', action='create',
+                                     repo_name=HG_REPO),
+                                 {'org_repo': HG_REPO,
+                                  'org_ref': 'branch:default:default',
+                                  'other_repo': HG_REPO,
+                                  'other_ref': 'branch:default:default',
+                                  'pullrequest_title': 'title',
+                                  'pullrequest_desc': 'description',
+                                  '_authentication_token': self.authentication_token(),
+                                 },
+                                 status=302)
+        pull_request1_id = re.search('/pull-request/(\d+)/', response.location).group(1)
+        assert response.location == 'http://localhost/%s/pull-request/%s/_/title' % (HG_REPO, pull_request1_id)
+
+        # create new iteration
+        response = self.app.post(url(controller='pullrequests', action='post',
+                                     repo_name=HG_REPO, pull_request_id=pull_request1_id),
+                                 {
+                                  'updaterev': 'default',
+                                  'pullrequest_title': 'title',
+                                  'pullrequest_desc': 'description',
+                                  'owner': TEST_USER_ADMIN_LOGIN,
+                                  '_authentication_token': self.authentication_token(),
+                                  'review_members': [regular_user.user_id],
+                                 },
+                                 status=302)
+        pull_request2_id = re.search('/pull-request/(\d+)/', response.location).group(1)
+        assert pull_request2_id != pull_request1_id
+        assert response.location == 'http://localhost/%s/pull-request/%s/_/title_v2' % (HG_REPO, pull_request2_id)
+        response = response.follow()
+        # verify reviewer was added
+        response.mustcontain('<input type="hidden" value="%s" name="review_members" />' % regular_user.user_id)
+
+        # update without creating new iteration
+        response = self.app.post(url(controller='pullrequests', action='post',
+                                     repo_name=HG_REPO, pull_request_id=pull_request2_id),
+                                 {
+                                  'pullrequest_title': 'Title',
+                                  'pullrequest_desc': 'description',
+                                  'owner': TEST_USER_ADMIN_LOGIN,
+                                  '_authentication_token': self.authentication_token(),
+                                  'review_members': [regular_user2.user_id],
+                                 },
+                                 status=302)
+        assert response.location == 'http://localhost/%s/pull-request/%s/_/Title' % (HG_REPO, pull_request2_id)
+        response = response.follow()
+        # verify reviewers were added / removed
+        response.mustcontain(no='<input type="hidden" value="%s" name="review_members" />' % regular_user.user_id)
+        response.mustcontain('<input type="hidden" value="%s" name="review_members" />' % regular_user2.user_id)
+
     def test_update_with_invalid_reviewer(self):
         invalid_user_id = 99999
         self.log_user()