Show More
@@ -32,42 +32,37 b' from rhodecode.api.tests.utils import (' | |||
|
32 | 32 | class TestMergePullRequest(object): |
|
33 | 33 | @pytest.mark.backends("git", "hg") |
|
34 | 34 | def test_api_merge_pull_request(self, pr_util, no_notifications): |
|
35 | pull_request = pr_util.create_pull_request() | |
|
36 | pull_request_2 = PullRequestModel().create( | |
|
37 | created_by=pull_request.author, | |
|
38 | source_repo=pull_request.source_repo, | |
|
39 | source_ref=pull_request.source_ref, | |
|
40 | target_repo=pull_request.target_repo, | |
|
41 | target_ref=pull_request.target_ref, | |
|
42 | revisions=pull_request.revisions, | |
|
43 | reviewers=(), | |
|
44 | title=pull_request.title, | |
|
45 | description=pull_request.description, | |
|
46 | ) | |
|
35 | pull_request = pr_util.create_pull_request(mergeable=True) | |
|
47 | 36 | author = pull_request.user_id |
|
48 |
repo = pull_request |
|
|
49 |
pull_request_ |
|
|
50 |
pull_request_ |
|
|
51 | Session().commit() | |
|
37 | repo = pull_request.target_repo.repo_id | |
|
38 | pull_request_id = pull_request.pull_request_id | |
|
39 | pull_request_repo = pull_request.target_repo.repo_name | |
|
52 | 40 | |
|
53 | 41 | id_, params = build_data( |
|
54 | 42 | self.apikey, 'merge_pull_request', |
|
55 |
repoid=pull_request_ |
|
|
56 |
pullrequestid=pull_request_ |
|
|
43 | repoid=pull_request_repo, | |
|
44 | pullrequestid=pull_request_id) | |
|
45 | ||
|
57 | 46 | response = api_call(self.app, params) |
|
58 | 47 | |
|
48 | # The above api call detaches the pull request DB object from the | |
|
49 | # session because of an unconditional transaction rollback in our | |
|
50 | # middleware. Therefore we need to add it back here if we want to use | |
|
51 | # it. | |
|
52 | Session().add(pull_request) | |
|
53 | ||
|
59 | 54 | expected = { |
|
60 | 55 | 'executed': True, |
|
61 | 56 | 'failure_reason': 0, |
|
62 | 'possible': True | |
|
57 | 'possible': True, | |
|
58 | 'merge_commit_id': pull_request.shadow_merge_ref.commit_id, | |
|
59 | 'merge_ref': pull_request.shadow_merge_ref._asdict() | |
|
63 | 60 | } |
|
64 | 61 | |
|
65 | 62 | response_json = response.json['result'] |
|
66 | assert response_json['merge_commit_id'] | |
|
67 | response_json.pop('merge_commit_id') | |
|
68 | 63 | assert response_json == expected |
|
69 | 64 | |
|
70 |
action = 'user_merged_pull_request:%d' % (pull_request_ |
|
|
65 | action = 'user_merged_pull_request:%d' % (pull_request_id, ) | |
|
71 | 66 | journal = UserLog.query()\ |
|
72 | 67 | .filter(UserLog.user_id == author)\ |
|
73 | 68 | .filter(UserLog.repository_id == repo)\ |
@@ -77,11 +72,11 b' class TestMergePullRequest(object):' | |||
|
77 | 72 | |
|
78 | 73 | id_, params = build_data( |
|
79 | 74 | self.apikey, 'merge_pull_request', |
|
80 |
repoid=pull_request_ |
|
|
75 | repoid=pull_request_repo, pullrequestid=pull_request_id) | |
|
81 | 76 | response = api_call(self.app, params) |
|
82 | 77 | |
|
83 | 78 | expected = 'pull request `%s` merge failed, pull request is closed' % ( |
|
84 |
pull_request_ |
|
|
79 | pull_request_id) | |
|
85 | 80 | assert_error(id_, expected, given=response.body) |
|
86 | 81 | |
|
87 | 82 | @pytest.mark.backends("git", "hg") |
General Comments 0
You need to be logged in to leave comments.
Login now