Show More
@@ -66,7 +66,7 b' class TestCreatePullRequestApi(object):' | |||||
66 | expected_message = "Created new pull request `{title}`".format( |
|
66 | expected_message = "Created new pull request `{title}`".format( | |
67 | title=data['title']) |
|
67 | title=data['title']) | |
68 | result = response.json |
|
68 | result = response.json | |
69 |
assert result['error'] |
|
69 | assert result['error'] is None | |
70 | assert result['result']['msg'] == expected_message |
|
70 | assert result['result']['msg'] == expected_message | |
71 | pull_request_id = result['result']['pull_request_id'] |
|
71 | pull_request_id = result['result']['pull_request_id'] | |
72 | pull_request = PullRequestModel().get(pull_request_id) |
|
72 | pull_request = PullRequestModel().get(pull_request_id) | |
@@ -89,7 +89,7 b' class TestCreatePullRequestApi(object):' | |||||
89 | expected_message = "Created new pull request `{title}`".format( |
|
89 | expected_message = "Created new pull request `{title}`".format( | |
90 | title=data['title']) |
|
90 | title=data['title']) | |
91 | result = response.json |
|
91 | result = response.json | |
92 |
assert result['error'] |
|
92 | assert result['error'] is None | |
93 | assert result['result']['msg'] == expected_message |
|
93 | assert result['result']['msg'] == expected_message | |
94 | pull_request_id = result['result']['pull_request_id'] |
|
94 | pull_request_id = result['result']['pull_request_id'] | |
95 | pull_request = PullRequestModel().get(pull_request_id) |
|
95 | pull_request = PullRequestModel().get(pull_request_id) | |
@@ -129,7 +129,7 b' class TestCreatePullRequestApi(object):' | |||||
129 | expected_message = "Created new pull request `{title}`".format( |
|
129 | expected_message = "Created new pull request `{title}`".format( | |
130 | title=data['title']) |
|
130 | title=data['title']) | |
131 | result = response.json |
|
131 | result = response.json | |
132 |
assert result['error'] |
|
132 | assert result['error'] is None | |
133 | assert result['result']['msg'] == expected_message |
|
133 | assert result['result']['msg'] == expected_message | |
134 | pull_request_id = result['result']['pull_request_id'] |
|
134 | pull_request_id = result['result']['pull_request_id'] | |
135 | pull_request = PullRequestModel().get(pull_request_id) |
|
135 | pull_request = PullRequestModel().get(pull_request_id) | |
@@ -144,11 +144,15 b' class TestCreatePullRequestApi(object):' | |||||
144 | entry['mandatory'] = rev.mandatory |
|
144 | entry['mandatory'] = rev.mandatory | |
145 | actual_reviewers.append(entry) |
|
145 | actual_reviewers.append(entry) | |
146 |
|
146 | |||
147 | # default reviewer will be added who is an owner of the repo |
|
147 | owner_username = pull_request.target_repo.user.username | |
148 | reviewers.append( |
|
148 | for spec_reviewer in reviewers[::]: | |
149 | {'username': pull_request.author.username, |
|
149 | # default reviewer will be added who is an owner of the repo | |
150 | 'reasons': [u'Default reviewer', u'Repository owner']}, |
|
150 | # this get's overridden by a add owner to reviewers rule | |
151 | ) |
|
151 | if spec_reviewer['username'] == owner_username: | |
|
152 | spec_reviewer['reasons'] = [u'Default reviewer', u'Repository owner'] | |||
|
153 | # since owner is more important, we don't inherit mandatory flag | |||
|
154 | del spec_reviewer['mandatory'] | |||
|
155 | ||||
152 | assert sorted(actual_reviewers, key=lambda e: e['username']) \ |
|
156 | assert sorted(actual_reviewers, key=lambda e: e['username']) \ | |
153 | == sorted(reviewers, key=lambda e: e['username']) |
|
157 | == sorted(reviewers, key=lambda e: e['username']) | |
154 |
|
158 | |||
@@ -173,7 +177,7 b' class TestCreatePullRequestApi(object):' | |||||
173 | expected_message = "Created new pull request `{title}`".format( |
|
177 | expected_message = "Created new pull request `{title}`".format( | |
174 | title=data['title']) |
|
178 | title=data['title']) | |
175 | result = response.json |
|
179 | result = response.json | |
176 |
assert result['error'] |
|
180 | assert result['error'] is None | |
177 | assert result['result']['msg'] == expected_message |
|
181 | assert result['result']['msg'] == expected_message | |
178 | pull_request_id = result['result']['pull_request_id'] |
|
182 | pull_request_id = result['result']['pull_request_id'] | |
179 | pull_request = PullRequestModel().get(pull_request_id) |
|
183 | pull_request = PullRequestModel().get(pull_request_id) | |
@@ -187,11 +191,14 b' class TestCreatePullRequestApi(object):' | |||||
187 | if rev.mandatory: |
|
191 | if rev.mandatory: | |
188 | entry['mandatory'] = rev.mandatory |
|
192 | entry['mandatory'] = rev.mandatory | |
189 | actual_reviewers.append(entry) |
|
193 | actual_reviewers.append(entry) | |
190 | # default reviewer will be added who is an owner of the repo |
|
194 | ||
191 | reviewers.append( |
|
195 | owner_user_id = pull_request.target_repo.user.user_id | |
192 | {'username': pull_request.author.user_id, |
|
196 | for spec_reviewer in reviewers[::]: | |
193 | 'reasons': [u'Default reviewer', u'Repository owner']}, |
|
197 | # default reviewer will be added who is an owner of the repo | |
194 | ) |
|
198 | # this get's overridden by a add owner to reviewers rule | |
|
199 | if spec_reviewer['username'] == owner_user_id: | |||
|
200 | spec_reviewer['reasons'] = [u'Default reviewer', u'Repository owner'] | |||
|
201 | ||||
195 | assert sorted(actual_reviewers, key=lambda e: e['username']) \ |
|
202 | assert sorted(actual_reviewers, key=lambda e: e['username']) \ | |
196 | == sorted(reviewers, key=lambda e: e['username']) |
|
203 | == sorted(reviewers, key=lambda e: e['username']) | |
197 |
|
204 |
@@ -51,12 +51,12 b' def get_default_reviewers_data(' | |||||
51 | """ Return json for default reviewers of a repository """ |
|
51 | """ Return json for default reviewers of a repository """ | |
52 |
|
52 | |||
53 | reasons = ['Default reviewer', 'Repository owner'] |
|
53 | reasons = ['Default reviewer', 'Repository owner'] | |
54 |
|
|
54 | json_reviewers = [reviewer_as_json( | |
55 |
user= |
|
55 | user=target_repo.user, reasons=reasons, mandatory=False, rules=None)] | |
56 |
|
56 | |||
57 | return { |
|
57 | return { | |
58 | 'api_ver': 'v1', # define version for later possible schema upgrade |
|
58 | 'api_ver': 'v1', # define version for later possible schema upgrade | |
59 |
'reviewers': |
|
59 | 'reviewers': json_reviewers, | |
60 | 'rules': {}, |
|
60 | 'rules': {}, | |
61 | 'rules_data': {}, |
|
61 | 'rules_data': {}, | |
62 | } |
|
62 | } |
General Comments 0
You need to be logged in to leave comments.
Login now