##// END OF EJS Templates
tests: Use only one place to define pr and shadow URL segments.
Martin Bornhold -
r920:c4b5ba79 default
parent child Browse files
Show More
@@ -174,34 +174,40 b' def test_should_check_locking(query_stri'
174 174
175 175
176 176 class TestShadowRepoRegularExpression(object):
177 pr_segment = 'pull-request'
178 shadow_segment = 'repository'
179
177 180 @pytest.mark.parametrize('url, expected', [
178 181 # repo with/without groups
179 ('My-Repo/pull-request/1/repository', True),
180 ('Group/My-Repo/pull-request/2/repository', True),
181 ('Group/Sub-Group/My-Repo/pull-request/3/repository', True),
182 ('Group/Sub-Group1/Sub-Group2/My-Repo/pull-request/3/repository', True),
182 ('My-Repo/{pr_segment}/1/{shadow_segment}', True),
183 ('Group/My-Repo/{pr_segment}/2/{shadow_segment}', True),
184 ('Group/Sub-Group/My-Repo/{pr_segment}/3/{shadow_segment}', True),
185 ('Group/Sub-Group1/Sub-Group2/My-Repo/{pr_segment}/3/{shadow_segment}', True),
183 186
184 187 # pull request ID
185 ('MyRepo/pull-request/1/repository', True),
186 ('MyRepo/pull-request/1234567890/repository', True),
187 ('MyRepo/pull-request/-1/repository', False),
188 ('MyRepo/pull-request/invalid/repository', False),
188 ('MyRepo/{pr_segment}/1/{shadow_segment}', True),
189 ('MyRepo/{pr_segment}/1234567890/{shadow_segment}', True),
190 ('MyRepo/{pr_segment}/-1/{shadow_segment}', False),
191 ('MyRepo/{pr_segment}/invalid/{shadow_segment}', False),
189 192
190 193 # unicode
191 (u'Sp€çîál-Repö/pull-request/1/repository', True),
192 (u'Sp€çîál-Gröüp/Sp€çîál-Repö/pull-request/1/repository', True),
194 (u'Sp€çîál-Repö/{pr_segment}/1/{shadow_segment}', True),
195 (u'Sp€çîál-Gröüp/Sp€çîál-Repö/{pr_segment}/1/{shadow_segment}', True),
193 196
194 197 # trailing/leading slash
195 ('/My-Repo/pull-request/1/repository', False),
196 ('My-Repo/pull-request/1/repository/', False),
197 ('/My-Repo/pull-request/1/repository/', False),
198 ('/My-Repo/{pr_segment}/1/{shadow_segment}', False),
199 ('My-Repo/{pr_segment}/1/{shadow_segment}/', False),
200 ('/My-Repo/{pr_segment}/1/{shadow_segment}/', False),
198 201
199 202 # misc
200 ('My-Repo/pull-request/1/repository/extra', False),
201 ('My-Repo/pull-request/1/repositoryextra', False),
203 ('My-Repo/{pr_segment}/1/{shadow_segment}/extra', False),
204 ('My-Repo/{pr_segment}/1/{shadow_segment}extra', False),
202 205 ])
203 206 def test_shadow_repo_regular_expression(self, url, expected):
204 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 211 match_obj = SimpleVCS.shadow_repo_re.match(url)
206 212 assert (match_obj is not None) == expected
207 213
@@ -276,9 +282,11 b' class TestShadowRepoExposure(object):'
276 282 from rhodecode.model.pull_request import PullRequestModel
277 283
278 284 pull_request = pr_util.create_pull_request()
279 shadow_url = '{target}/pull-request/{pr_id}/repository'.format(
285 shadow_url = '{target}/{pr_segment}/{pr_id}/{shadow_segment}'.format(
280 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 290 controller = StubVCSController(pylonsapp, pylonsapp.config, None)
283 291 controller._name = shadow_url
284 292 controller.set_repo_names({})
@@ -301,9 +309,11 b' class TestShadowRepoExposure(object):'
301 309 and pull request IDs.
302 310 """
303 311 pull_request = pr_util.create_pull_request()
304 shadow_url = '{target}/pull-request/{pr_id}/repository'.format(
312 shadow_url = '{target}/{pr_segment}/{pr_id}/{shadow_segment}'.format(
305 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 317 controller = StubVCSController(pylonsapp, pylonsapp.config, None)
308 318 controller._name = shadow_url
309 319 controller.set_repo_names({})
General Comments 0
You need to be logged in to leave comments. Login now