Debian Codegraph @

third_party/python/mozilla_repo_urls/test/test_integration.py

raw
1 from test import does_not_raise
2
3 import pytest
4
5 import mozilla_repo_urls
6
7
8 @pytest.mark.parametrize(
9 "url_string, expectation, expected",
10 (
11 (
12 "https://hg.mozilla.org/mozilla-central",
13 does_not_raise(),
14 {
15 "github": False,
16 "git_cinnabar": False,
17 "groups": [],
18 "hgmo": True,
19 "host": "hg.mozilla.org",
20 "name": "mozilla-central",
21 "normalized": "https://hg.mozilla.org/mozilla-central",
22 "path_raw": "",
23 "path": "",
24 "pathname": "/mozilla-central",
25 "platform": "hgmo",
26 "port": "",
27 "protocol": "https",
28 "protocols": ["https"],
29 "repo": "mozilla-central",
30 "repo_name": "mozilla-central",
31 "repo_path": "mozilla-central",
32 "repo_type": "hg",
33 "resource": "hg.mozilla.org",
34 "taskcluster_role_prefix": "repo:hg.mozilla.org/mozilla-central",
35 "urls": {
36 "hg": "hg://hg.mozilla.org:https/mozilla-central",
37 "https": "https://hg.mozilla.org/mozilla-central",
38 "ssh": "ssh://hg.mozilla.org/mozilla-central",
39 },
40 "user": "",
41 "valid": True,
42 },
43 ),
44 (
45 "https://hg.mozilla.org/releases/mozilla-beta",
46 does_not_raise(),
47 {
48 "github": False,
49 "git_cinnabar": False,
50 "groups": [],
51 "hgmo": True,
52 "host": "hg.mozilla.org",
53 "name": "releases/mozilla-beta",
54 "normalized": "https://hg.mozilla.org/releases/mozilla-beta",
55 "path_raw": "",
56 "path": "",
57 "pathname": "/releases/mozilla-beta",
58 "platform": "hgmo",
59 "port": "",
60 "protocol": "https",
61 "protocols": ["https"],
62 "repo": "releases/mozilla-beta",
63 "repo_name": "mozilla-beta",
64 "repo_path": "releases/mozilla-beta",
65 "repo_type": "hg",
66 "resource": "hg.mozilla.org",
67 "taskcluster_role_prefix": "repo:hg.mozilla.org/releases/mozilla-beta",
68 "urls": {
69 "hg": "hg://hg.mozilla.org:https/releases/mozilla-beta",
70 "https": "https://hg.mozilla.org/releases/mozilla-beta",
71 "ssh": "ssh://hg.mozilla.org/releases/mozilla-beta",
72 },
73 "user": "",
74 "valid": True,
75 },
76 ),
77 (
78 "https://hg.mozilla.org/releases/mozilla-release",
79 does_not_raise(),
80 {
81 "github": False,
82 "git_cinnabar": False,
83 "groups": [],
84 "hgmo": True,
85 "host": "hg.mozilla.org",
86 "name": "releases/mozilla-release",
87 "normalized": "https://hg.mozilla.org/releases/mozilla-release",
88 "path_raw": "",
89 "path": "",
90 "pathname": "/releases/mozilla-release",
91 "platform": "hgmo",
92 "port": "",
93 "protocol": "https",
94 "protocols": ["https"],
95 "repo": "releases/mozilla-release",
96 "repo_name": "mozilla-release",
97 "repo_path": "releases/mozilla-release",
98 "repo_type": "hg",
99 "resource": "hg.mozilla.org",
100 "taskcluster_role_prefix": "repo:hg.mozilla.org/releases/mozilla-release", # noqa: E501
101 "urls": {
102 "hg": "hg://hg.mozilla.org:https/releases/mozilla-release",
103 "https": "https://hg.mozilla.org/releases/mozilla-release",
104 "ssh": "ssh://hg.mozilla.org/releases/mozilla-release",
105 },
106 "user": "",
107 "valid": True,
108 },
109 ),
110 (
111 "https://hg.mozilla.org/try",
112 does_not_raise(),
113 {
114 "github": False,
115 "git_cinnabar": False,
116 "groups": [],
117 "hgmo": True,
118 "host": "hg.mozilla.org",
119 "name": "try",
120 "normalized": "https://hg.mozilla.org/try",
121 "path_raw": "",
122 "path": "",
123 "pathname": "/try",
124 "platform": "hgmo",
125 "port": "",
126 "protocol": "https",
127 "protocols": ["https"],
128 "repo": "try",
129 "repo_name": "try",
130 "repo_path": "try",
131 "repo_type": "hg",
132 "resource": "hg.mozilla.org",
133 "taskcluster_role_prefix": "repo:hg.mozilla.org/try",
134 "urls": {
135 "hg": "hg://hg.mozilla.org:https/try",
136 "https": "https://hg.mozilla.org/try",
137 "ssh": "ssh://hg.mozilla.org/try",
138 },
139 "user": "",
140 "valid": True,
141 },
142 ),
143 (
144 "https://hg.mozilla.org/mozilla-central/raw-file/tip/taskcluster/ci/config.yml", # noqa: E501
145 does_not_raise(),
146 {
147 "github": False,
148 "git_cinnabar": False,
149 "groups": [],
150 "hgmo": True,
151 "host": "hg.mozilla.org",
152 "name": "mozilla-central",
153 "normalized": "https://hg.mozilla.org/mozilla-central/raw-file/tip/taskcluster/ci/config.yml", # noqa: E501
154 "path_raw": "/raw-file/tip/taskcluster/ci/config.yml",
155 "path": "tip/taskcluster/ci/config.yml",
156 "pathname": "/mozilla-central",
157 "platform": "hgmo",
158 "port": "",
159 "protocol": "https",
160 "protocols": ["https"],
161 "repo": "mozilla-central",
162 "repo_name": "mozilla-central",
163 "repo_path": "mozilla-central",
164 "repo_type": "hg",
165 "resource": "hg.mozilla.org",
166 "taskcluster_role_prefix": "repo:hg.mozilla.org/mozilla-central",
167 "urls": {
168 "hg": "hg://hg.mozilla.org:https/mozilla-central",
169 "https": "https://hg.mozilla.org/mozilla-central/raw-file/tip/taskcluster/ci/config.yml", # noqa: E501
170 "ssh": "ssh://hg.mozilla.org/mozilla-central",
171 },
172 "user": "",
173 "valid": True,
174 },
175 ),
176 (
177 "https://hg.mozilla.org/mozilla-central/file/tip/taskcluster/ci/config.yml", # noqa: E501
178 does_not_raise(),
179 {
180 "github": False,
181 "git_cinnabar": False,
182 "groups": [],
183 "hgmo": True,
184 "host": "hg.mozilla.org",
185 "name": "mozilla-central",
186 "normalized": "https://hg.mozilla.org/mozilla-central/file/tip/taskcluster/ci/config.yml", # noqa: E501
187 "path_raw": "/file/tip/taskcluster/ci/config.yml",
188 "path": "tip/taskcluster/ci/config.yml",
189 "pathname": "/mozilla-central",
190 "platform": "hgmo",
191 "port": "",
192 "protocol": "https",
193 "protocols": ["https"],
194 "repo": "mozilla-central",
195 "repo_name": "mozilla-central",
196 "repo_path": "mozilla-central",
197 "repo_type": "hg",
198 "resource": "hg.mozilla.org",
199 "taskcluster_role_prefix": "repo:hg.mozilla.org/mozilla-central",
200 "urls": {
201 "hg": "hg://hg.mozilla.org:https/mozilla-central",
202 "https": "https://hg.mozilla.org/mozilla-central/file/tip/taskcluster/ci/config.yml", # noqa: E501
203 "ssh": "ssh://hg.mozilla.org/mozilla-central",
204 },
205 "user": "",
206 "valid": True,
207 },
208 ),
209 (
210 "https://github.com/mozilla-mobile/fenix",
211 does_not_raise(),
212 {
213 "github": True,
214 "git_cinnabar": False,
215 "groups": [],
216 "hgmo": False,
217 "host": "github.com",
218 "name": "fenix",
219 "normalized": "https://github.com/mozilla-mobile/fenix.git",
220 "owner": "mozilla-mobile",
221 "path_raw": "",
222 "path": "",
223 "pathname": "/mozilla-mobile/fenix",
224 "platform": "github",
225 "port": "",
226 "protocol": "https",
227 "protocols": ["https"],
228 "repo": "fenix",
229 "repo_name": "fenix",
230 "repo_path": "mozilla-mobile/fenix",
231 "repo_type": "git",
232 "resource": "github.com",
233 "taskcluster_role_prefix": "repo:github.com/mozilla-mobile/fenix",
234 "urls": {
235 "git": "git://github.com/mozilla-mobile/fenix.git",
236 "https": "https://github.com/mozilla-mobile/fenix.git",
237 "ssh": "[email protected]:mozilla-mobile/fenix.git",
238 },
239 "user": "git",
240 "valid": True,
241 },
242 ),
243 (
244 "[email protected]:mozilla-mobile/firefox-android.git",
245 does_not_raise(),
246 {
247 "github": True,
248 "git_cinnabar": False,
249 "groups": [],
250 "hgmo": False,
251 "host": "github.com",
252 "name": "firefox-android",
253 "normalized": "[email protected]:mozilla-mobile/firefox-android.git",
254 "owner": "mozilla-mobile",
255 "path_raw": "",
256 "path": "",
257 "pathname": "mozilla-mobile/firefox-android.git",
258 "platform": "github",
259 "port": "",
260 "protocol": "ssh",
261 "protocols": [],
262 "repo": "firefox-android",
263 "repo_name": "firefox-android",
264 "repo_path": "mozilla-mobile/firefox-android",
265 "repo_type": "git",
266 "resource": "github.com",
267 "taskcluster_role_prefix": "repo:github.com/mozilla-mobile/firefox-android", # noqa: E501
268 "urls": {
269 "git": "git://github.com/mozilla-mobile/firefox-android.git",
270 "https": "https://github.com/mozilla-mobile/firefox-android.git",
271 "ssh": "[email protected]:mozilla-mobile/firefox-android.git",
272 },
273 "user": "git",
274 "valid": True,
275 },
276 ),
277 (
278 "ssh://hg.mozilla.org/mozilla-unified",
279 does_not_raise(),
280 {
281 "github": False,
282 "groups": [],
283 "hgmo": True,
284 "host": "hg.mozilla.org",
285 "name": "mozilla-unified",
286 "normalized": "ssh://hg.mozilla.org/mozilla-unified",
287 "path_raw": "",
288 "path": "",
289 "pathname": "/mozilla-unified",
290 "platform": "hgmo",
291 "port": "",
292 "protocol": "ssh",
293 "protocols": ["ssh"],
294 "repo": "mozilla-unified",
295 "repo_name": "mozilla-unified",
296 "repo_path": "mozilla-unified",
297 "repo_type": "hg",
298 "resource": "hg.mozilla.org",
299 "taskcluster_role_prefix": "repo:hg.mozilla.org/mozilla-unified",
300 "urls": {
301 "hg": "hg://hg.mozilla.org:ssh/mozilla-unified",
302 "https": "https://hg.mozilla.org/mozilla-unified",
303 "ssh": "ssh://hg.mozilla.org/mozilla-unified",
304 },
305 "user": "",
306 "valid": True,
307 },
308 ),
309 (
310 "hg::https://hg.mozilla.org/mozilla-unified",
311 does_not_raise(),
312 {
313 "github": False,
314 "git_cinnabar": True,
315 "groups": [],
316 "hgmo": True,
317 "host": "hg.mozilla.org",
318 "name": "mozilla-unified",
319 "normalized": "https://hg.mozilla.org/mozilla-unified",
320 "path_raw": "",
321 "path": "",
322 "pathname": "/mozilla-unified",
323 "platform": "hgmo",
324 "port": "",
325 "protocol": "https",
326 "protocols": ["hg::https"],
327 "repo": "mozilla-unified",
328 "repo_name": "mozilla-unified",
329 "repo_path": "mozilla-unified",
330 "repo_type": "git",
331 "resource": "hg.mozilla.org",
332 "taskcluster_role_prefix": "repo:hg.mozilla.org/mozilla-unified",
333 "urls": {
334 "hg": "hg://hg.mozilla.org:https/mozilla-unified",
335 "https": "https://hg.mozilla.org/mozilla-unified",
336 "ssh": "ssh://hg.mozilla.org/mozilla-unified",
337 },
338 "user": "",
339 "valid": True,
340 },
341 ),
342 (
343 "hg::ssh://hg.mozilla.org/mozilla-unified",
344 does_not_raise(),
345 {
346 "github": False,
347 "git_cinnabar": True,
348 "groups": [],
349 "hgmo": True,
350 "host": "hg.mozilla.org",
351 "name": "mozilla-unified",
352 "normalized": "ssh://hg.mozilla.org/mozilla-unified",
353 "path_raw": "",
354 "path": "",
355 "pathname": "/mozilla-unified",
356 "platform": "hgmo",
357 "port": "",
358 "protocol": "ssh",
359 "protocols": ["hg::ssh"],
360 "repo": "mozilla-unified",
361 "repo_name": "mozilla-unified",
362 "repo_path": "mozilla-unified",
363 "repo_type": "git",
364 "resource": "hg.mozilla.org",
365 "taskcluster_role_prefix": "repo:hg.mozilla.org/mozilla-unified",
366 "urls": {
367 "hg": "hg://hg.mozilla.org:ssh/mozilla-unified",
368 "https": "https://hg.mozilla.org/mozilla-unified",
369 "ssh": "ssh://hg.mozilla.org/mozilla-unified",
370 },
371 "user": "",
372 "valid": True,
373 },
374 ),
375 (
376 "hg://hg.mozilla.org/mozilla-central",
377 does_not_raise(),
378 {
379 "github": False,
380 "git_cinnabar": True,
381 "groups": [],
382 "hgmo": True,
383 "host": "hg.mozilla.org",
384 "name": "mozilla-central",
385 "normalized": "hg://hg.mozilla.org:https/mozilla-central",
386 "path_raw": "",
387 "path": "",
388 "pathname": "/mozilla-central",
389 "platform": "hgmo",
390 "port": "",
391 "protocol": "hg",
392 "protocols": ["hg::https"],
393 "repo": "mozilla-central",
394 "repo_name": "mozilla-central",
395 "repo_path": "mozilla-central",
396 "repo_type": "git",
397 "resource": "hg.mozilla.org",
398 "taskcluster_role_prefix": "repo:hg.mozilla.org/mozilla-central",
399 "urls": {
400 "hg": "hg://hg.mozilla.org:https/mozilla-central",
401 "https": "https://hg.mozilla.org/mozilla-central",
402 "ssh": "ssh://hg.mozilla.org/mozilla-central",
403 },
404 "user": "",
405 "valid": True,
406 },
407 ),
408 (
409 "hg://hg.mozilla.org:https/mozilla-central",
410 does_not_raise(),
411 {
412 "github": False,
413 "git_cinnabar": True,
414 "groups": [],
415 "hgmo": True,
416 "host": "hg.mozilla.org",
417 "name": "mozilla-central",
418 "normalized": "hg://hg.mozilla.org:https/mozilla-central",
419 "path_raw": "",
420 "path": "",
421 "pathname": "/mozilla-central",
422 "platform": "hgmo",
423 "port": "",
424 "protocol": "hg",
425 "protocols": ["hg::https"],
426 "repo": "mozilla-central",
427 "repo_name": "mozilla-central",
428 "repo_path": "mozilla-central",
429 "repo_type": "git",
430 "resource": "hg.mozilla.org",
431 "taskcluster_role_prefix": "repo:hg.mozilla.org/mozilla-central",
432 "urls": {
433 "hg": "hg://hg.mozilla.org:https/mozilla-central",
434 "https": "https://hg.mozilla.org/mozilla-central",
435 "ssh": "ssh://hg.mozilla.org/mozilla-central",
436 },
437 "user": "",
438 "valid": True,
439 },
440 ),
441 (
442 "hg://hg.mozilla.org:ssh/mozilla-central",
443 does_not_raise(),
444 {
445 "github": False,
446 "git_cinnabar": True,
447 "groups": [],
448 "hgmo": True,
449 "host": "hg.mozilla.org",
450 "name": "mozilla-central",
451 "normalized": "hg://hg.mozilla.org:ssh/mozilla-central",
452 "path_raw": "",
453 "path": "",
454 "pathname": "/mozilla-central",
455 "platform": "hgmo",
456 "port": "",
457 "protocol": "hg",
458 "protocols": ["hg::ssh"],
459 "repo": "mozilla-central",
460 "repo_name": "mozilla-central",
461 "repo_path": "mozilla-central",
462 "repo_type": "git",
463 "resource": "hg.mozilla.org",
464 "taskcluster_role_prefix": "repo:hg.mozilla.org/mozilla-central",
465 "urls": {
466 "hg": "hg://hg.mozilla.org:ssh/mozilla-central",
467 "https": "https://hg.mozilla.org/mozilla-central",
468 "ssh": "ssh://hg.mozilla.org/mozilla-central",
469 },
470 "user": "",
471 "valid": True,
472 },
473 ),
474 (
475 "https://some.unknown/repo",
476 pytest.raises(mozilla_repo_urls.InvalidRepoUrlError),
477 None,
478 ),
479 (
480 "https://gitlab.com/some-owner/some-repo",
481 pytest.raises(mozilla_repo_urls.UnsupportedPlatformError),
482 None,
483 ),
484 ),
485 )
486 def test_parse(url_string, expectation, expected):
487 with expectation:
488 url_object = mozilla_repo_urls.parse(url_string)
489 actual = {
490 attribute_name: getattr(url_object, attribute_name)
491 for attribute_name in expected.keys()
492 }
493 assert actual == expected