Show More
@@ -174,34 +174,40 b' def test_should_check_locking(query_stri' | |||||
174 |
|
174 | |||
175 |
|
175 | |||
176 | class TestShadowRepoRegularExpression(object): |
|
176 | class TestShadowRepoRegularExpression(object): | |
|
177 | pr_segment = 'pull-request' | |||
|
178 | shadow_segment = 'repository' | |||
|
179 | ||||
177 | @pytest.mark.parametrize('url, expected', [ |
|
180 | @pytest.mark.parametrize('url, expected', [ | |
178 | # repo with/without groups |
|
181 | # repo with/without groups | |
179 |
('My-Repo/ |
|
182 | ('My-Repo/{pr_segment}/1/{shadow_segment}', True), | |
180 |
('Group/My-Repo/ |
|
183 | ('Group/My-Repo/{pr_segment}/2/{shadow_segment}', True), | |
181 |
('Group/Sub-Group/My-Repo/ |
|
184 | ('Group/Sub-Group/My-Repo/{pr_segment}/3/{shadow_segment}', True), | |
182 |
('Group/Sub-Group1/Sub-Group2/My-Repo/ |
|
185 | ('Group/Sub-Group1/Sub-Group2/My-Repo/{pr_segment}/3/{shadow_segment}', True), | |
183 |
|
186 | |||
184 | # pull request ID |
|
187 | # pull request ID | |
185 |
('MyRepo/ |
|
188 | ('MyRepo/{pr_segment}/1/{shadow_segment}', True), | |
186 |
('MyRepo/ |
|
189 | ('MyRepo/{pr_segment}/1234567890/{shadow_segment}', True), | |
187 |
('MyRepo/ |
|
190 | ('MyRepo/{pr_segment}/-1/{shadow_segment}', False), | |
188 |
('MyRepo/ |
|
191 | ('MyRepo/{pr_segment}/invalid/{shadow_segment}', False), | |
189 |
|
192 | |||
190 | # unicode |
|
193 | # unicode | |
191 |
(u'Sp€çîál-Repö/ |
|
194 | (u'Sp€çîál-Repö/{pr_segment}/1/{shadow_segment}', True), | |
192 |
(u'Sp€çîál-Gröüp/Sp€çîál-Repö/ |
|
195 | (u'Sp€çîál-Gröüp/Sp€çîál-Repö/{pr_segment}/1/{shadow_segment}', True), | |
193 |
|
196 | |||
194 | # trailing/leading slash |
|
197 | # trailing/leading slash | |
195 |
('/My-Repo/ |
|
198 | ('/My-Repo/{pr_segment}/1/{shadow_segment}', False), | |
196 |
('My-Repo/ |
|
199 | ('My-Repo/{pr_segment}/1/{shadow_segment}/', False), | |
197 |
('/My-Repo/ |
|
200 | ('/My-Repo/{pr_segment}/1/{shadow_segment}/', False), | |
198 |
|
201 | |||
199 | # misc |
|
202 | # misc | |
200 |
('My-Repo/ |
|
203 | ('My-Repo/{pr_segment}/1/{shadow_segment}/extra', False), | |
201 |
('My-Repo/ |
|
204 | ('My-Repo/{pr_segment}/1/{shadow_segment}extra', False), | |
202 | ]) |
|
205 | ]) | |
203 | def test_shadow_repo_regular_expression(self, url, expected): |
|
206 | def test_shadow_repo_regular_expression(self, url, expected): | |
204 | from rhodecode.lib.middleware.simplevcs import SimpleVCS |
|
207 | from rhodecode.lib.middleware.simplevcs import SimpleVCS | |
|
208 | url = url.format( | |||
|
209 | pr_segment=self.pr_segment, | |||
|
210 | shadow_segment=self.shadow_segment) | |||
205 | match_obj = SimpleVCS.shadow_repo_re.match(url) |
|
211 | match_obj = SimpleVCS.shadow_repo_re.match(url) | |
206 | assert (match_obj is not None) == expected |
|
212 | assert (match_obj is not None) == expected | |
207 |
|
213 | |||
@@ -276,9 +282,11 b' class TestShadowRepoExposure(object):' | |||||
276 | from rhodecode.model.pull_request import PullRequestModel |
|
282 | from rhodecode.model.pull_request import PullRequestModel | |
277 |
|
283 | |||
278 | pull_request = pr_util.create_pull_request() |
|
284 | pull_request = pr_util.create_pull_request() | |
279 |
shadow_url = '{target}/ |
|
285 | shadow_url = '{target}/{pr_segment}/{pr_id}/{shadow_segment}'.format( | |
280 | target=pull_request.target_repo.repo_name, |
|
286 | target=pull_request.target_repo.repo_name, | |
281 |
pr_id=pull_request.pull_request_id |
|
287 | pr_id=pull_request.pull_request_id, | |
|
288 | pr_segment=TestShadowRepoRegularExpression.pr_segment, | |||
|
289 | shadow_segment=TestShadowRepoRegularExpression.shadow_segment) | |||
282 | controller = StubVCSController(pylonsapp, pylonsapp.config, None) |
|
290 | controller = StubVCSController(pylonsapp, pylonsapp.config, None) | |
283 | controller._name = shadow_url |
|
291 | controller._name = shadow_url | |
284 | controller.set_repo_names({}) |
|
292 | controller.set_repo_names({}) | |
@@ -301,9 +309,11 b' class TestShadowRepoExposure(object):' | |||||
301 | and pull request IDs. |
|
309 | and pull request IDs. | |
302 | """ |
|
310 | """ | |
303 | pull_request = pr_util.create_pull_request() |
|
311 | pull_request = pr_util.create_pull_request() | |
304 |
shadow_url = '{target}/ |
|
312 | shadow_url = '{target}/{pr_segment}/{pr_id}/{shadow_segment}'.format( | |
305 | target=pull_request.target_repo.repo_name, |
|
313 | target=pull_request.target_repo.repo_name, | |
306 |
pr_id=999999999 |
|
314 | pr_id=999999999, | |
|
315 | pr_segment=TestShadowRepoRegularExpression.pr_segment, | |||
|
316 | shadow_segment=TestShadowRepoRegularExpression.shadow_segment) | |||
307 | controller = StubVCSController(pylonsapp, pylonsapp.config, None) |
|
317 | controller = StubVCSController(pylonsapp, pylonsapp.config, None) | |
308 | controller._name = shadow_url |
|
318 | controller._name = shadow_url | |
309 | controller.set_repo_names({}) |
|
319 | controller.set_repo_names({}) |
General Comments 0
You need to be logged in to leave comments.
Login now