Show More
@@ -24,7 +24,8 b' from rhodecode.lib.vcs.nodes import File' | |||
|
24 | 24 | from rhodecode.model.db import User |
|
25 | 25 | from rhodecode.model.pull_request import PullRequestModel |
|
26 | 26 | from rhodecode.tests import TEST_USER_ADMIN_LOGIN |
|
27 |
from rhodecode.api.tests.utils import ( |
|
|
27 | from rhodecode.api.tests.utils import ( | |
|
28 | build_data, api_call, assert_ok, assert_error) | |
|
28 | 29 | |
|
29 | 30 | |
|
30 | 31 | @pytest.mark.usefixtures("testuser_api", "app") |
@@ -74,8 +75,7 b' class TestUpdatePullRequest(object):' | |||
|
74 | 75 | expected = 'pull request `{}` update failed, pull request ' \ |
|
75 | 76 | 'is closed'.format(pull_request.pull_request_id) |
|
76 | 77 | |
|
77 | response_json = response.json['error'] | |
|
78 | assert response_json == expected | |
|
78 | assert_error(id_, expected, response.body) | |
|
79 | 79 | |
|
80 | 80 | @pytest.mark.backends("git", "hg") |
|
81 | 81 | def test_api_update_update_commits( |
@@ -90,9 +90,11 b' class TestUpdatePullRequest(object):' | |||
|
90 | 90 | pr_util.update_source_repository(head='c') |
|
91 | 91 | repo = pull_request.source_repo.scm_instance() |
|
92 | 92 | commits = [x for x in repo.get_commits()] |
|
93 | print commits | |
|
93 | 94 | |
|
94 | 95 | added_commit_id = commits[-1].raw_id # c commit |
|
95 |
common_commit |
|
|
96 | common_commit_id = commits[1].raw_id # b commit is common ancestor | |
|
97 | total_commits = [added_commit_id, common_commit_id] | |
|
96 | 98 | |
|
97 | 99 | id_, params = build_data( |
|
98 | 100 | self.apikey, 'update_pull_request', |
@@ -107,12 +109,13 b' class TestUpdatePullRequest(object):' | |||
|
107 | 109 | pull_request.pull_request_id), |
|
108 | 110 | "pull_request": response.json['result']['pull_request'], |
|
109 | 111 | "updated_commits": {"added": [added_commit_id], |
|
110 |
"common": [common_commit |
|
|
112 | "common": [common_commit_id], | |
|
113 | "total": total_commits, | |
|
114 | "removed": []}, | |
|
111 | 115 | "updated_reviewers": {"added": [], "removed": []}, |
|
112 | 116 | } |
|
113 | 117 | |
|
114 | response_json = response.json['result'] | |
|
115 | assert response_json == expected | |
|
118 | assert_ok(id_, expected, response.body) | |
|
116 | 119 | |
|
117 | 120 | @pytest.mark.backends("git", "hg") |
|
118 | 121 | def test_api_update_change_reviewers( |
@@ -139,8 +142,7 b' class TestUpdatePullRequest(object):' | |||
|
139 | 142 | "updated_reviewers": {"added": added, "removed": removed}, |
|
140 | 143 | } |
|
141 | 144 | |
|
142 | response_json = response.json['result'] | |
|
143 | assert response_json == expected | |
|
145 | assert_ok(id_, expected, response.body) | |
|
144 | 146 | |
|
145 | 147 | @pytest.mark.backends("git", "hg") |
|
146 | 148 | def test_api_update_bad_user_in_reviewers(self, pr_util): |
@@ -155,8 +157,7 b' class TestUpdatePullRequest(object):' | |||
|
155 | 157 | |
|
156 | 158 | expected = 'user `bad_name` does not exist' |
|
157 | 159 | |
|
158 | response_json = response.json['error'] | |
|
159 | assert response_json == expected | |
|
160 | assert_error(id_, expected, response.body) | |
|
160 | 161 | |
|
161 | 162 | @pytest.mark.backends("git", "hg") |
|
162 | 163 | def test_api_update_repo_error(self, pr_util): |
@@ -184,9 +185,7 b' class TestUpdatePullRequest(object):' | |||
|
184 | 185 | response = api_call(self.app, params) |
|
185 | 186 | |
|
186 | 187 | expected = 'pull request `999999` does not exist' |
|
187 | ||
|
188 | response_json = response.json['error'] | |
|
189 | assert response_json == expected | |
|
188 | assert_error(id_, expected, response.body) | |
|
190 | 189 | |
|
191 | 190 | @pytest.mark.backends("git", "hg") |
|
192 | 191 | def test_api_update_pull_request_no_perms_to_update( |
@@ -203,5 +202,4 b' class TestUpdatePullRequest(object):' | |||
|
203 | 202 | expected = ('pull request `%s` update failed, ' |
|
204 | 203 | 'no permission to update.') % pull_request.pull_request_id |
|
205 | 204 | |
|
206 | response_json = response.json['error'] | |
|
207 | assert response_json == expected | |
|
205 | assert_error(id_, expected, response.body) |
@@ -356,8 +356,11 b' class TestPullRequestModel:' | |||
|
356 | 356 | assert commit_ids == pull_request.revisions + [pull_request.merge_rev] |
|
357 | 357 | |
|
358 | 358 | def test_get_diff_from_pr_version(self, pull_request): |
|
359 | source_repo = pull_request.source_repo | |
|
360 | source_ref_id = pull_request.source_ref_parts.commit_id | |
|
361 | target_ref_id = pull_request.target_ref_parts.commit_id | |
|
359 | 362 | diff = PullRequestModel()._get_diff_from_pr_or_version( |
|
360 |
|
|
|
363 | source_repo, source_ref_id, target_ref_id, context=6) | |
|
361 | 364 | assert 'file_1' in diff.raw |
|
362 | 365 | |
|
363 | 366 | def test_generate_title_returns_unicode(self): |
@@ -803,10 +806,13 b' def test_link_comments_to_version_only_u' | |||
|
803 | 806 | |
|
804 | 807 | |
|
805 | 808 | def test_calculate_commits(): |
|
806 | change = PullRequestModel()._calculate_commit_id_changes( | |
|
807 | set([1, 2, 3]), set([1, 3, 4, 5])) | |
|
808 | assert (set([4, 5]), set([1, 3]), set([2])) == ( | |
|
809 | change.added, change.common, change.removed) | |
|
809 | old_ids = [1, 2, 3] | |
|
810 | new_ids = [1, 3, 4, 5] | |
|
811 | change = PullRequestModel()._calculate_commit_id_changes(old_ids, new_ids) | |
|
812 | assert change.added == [4, 5] | |
|
813 | assert change.common == [1, 3] | |
|
814 | assert change.removed == [2] | |
|
815 | assert change.total == [1, 3, 4, 5] | |
|
810 | 816 | |
|
811 | 817 | |
|
812 | 818 | def assert_inline_comments(pull_request, visible=None, outdated=None): |
@@ -55,8 +55,11 b' class TestGetDiffForPrOrVersion(object):' | |||
|
55 | 55 | return pull_request |
|
56 | 56 | |
|
57 | 57 | def assert_diff_can_be_fetched(self, pr_or_version): |
|
58 | source_repo = pr_or_version.source_repo | |
|
59 | source_ref_id = pr_or_version.source_ref_parts.commit_id | |
|
60 | target_ref_id = pr_or_version.target_ref_parts.commit_id | |
|
58 | 61 | diff = PullRequestModel()._get_diff_from_pr_or_version( |
|
59 |
|
|
|
62 | source_repo, source_ref_id, target_ref_id, context=6) | |
|
60 | 63 | assert 'file_b' in diff.raw |
|
61 | 64 | |
|
62 | 65 | def assert_commit_cannot_be_accessed( |
General Comments 0
You need to be logged in to leave comments.
Login now