diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /third_party/python/mozilla_repo_urls/test | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/python/mozilla_repo_urls/test')
3 files changed, 508 insertions, 0 deletions
diff --git a/third_party/python/mozilla_repo_urls/test/__init__.py b/third_party/python/mozilla_repo_urls/test/__init__.py new file mode 100644 index 0000000000..8010adcb1c --- /dev/null +++ b/third_party/python/mozilla_repo_urls/test/__init__.py @@ -0,0 +1,6 @@ +from contextlib import contextmanager + + +@contextmanager +def does_not_raise(): + yield diff --git a/third_party/python/mozilla_repo_urls/test/test_integration.py b/third_party/python/mozilla_repo_urls/test/test_integration.py new file mode 100644 index 0000000000..200c492227 --- /dev/null +++ b/third_party/python/mozilla_repo_urls/test/test_integration.py @@ -0,0 +1,493 @@ +from test import does_not_raise + +import pytest + +import mozilla_repo_urls + + +@pytest.mark.parametrize( + "url_string, expectation, expected", + ( + ( + "https://hg.mozilla.org/mozilla-central", + does_not_raise(), + { + "github": False, + "git_cinnabar": False, + "groups": [], + "hgmo": True, + "host": "hg.mozilla.org", + "name": "mozilla-central", + "normalized": "https://hg.mozilla.org/mozilla-central", + "path_raw": "", + "path": "", + "pathname": "/mozilla-central", + "platform": "hgmo", + "port": "", + "protocol": "https", + "protocols": ["https"], + "repo": "mozilla-central", + "repo_name": "mozilla-central", + "repo_path": "mozilla-central", + "repo_type": "hg", + "resource": "hg.mozilla.org", + "taskcluster_role_prefix": "repo:hg.mozilla.org/mozilla-central", + "urls": { + "hg": "hg://hg.mozilla.org:https/mozilla-central", + "https": "https://hg.mozilla.org/mozilla-central", + "ssh": "ssh://hg.mozilla.org/mozilla-central", + }, + "user": "", + "valid": True, + }, + ), + ( + "https://hg.mozilla.org/releases/mozilla-beta", + does_not_raise(), + { + "github": False, + "git_cinnabar": False, + "groups": [], + "hgmo": True, + "host": "hg.mozilla.org", + "name": "releases/mozilla-beta", + "normalized": "https://hg.mozilla.org/releases/mozilla-beta", + "path_raw": "", + "path": "", + "pathname": "/releases/mozilla-beta", + "platform": "hgmo", + "port": "", + "protocol": "https", + "protocols": ["https"], + "repo": "releases/mozilla-beta", + "repo_name": "mozilla-beta", + "repo_path": "releases/mozilla-beta", + "repo_type": "hg", + "resource": "hg.mozilla.org", + "taskcluster_role_prefix": "repo:hg.mozilla.org/releases/mozilla-beta", + "urls": { + "hg": "hg://hg.mozilla.org:https/releases/mozilla-beta", + "https": "https://hg.mozilla.org/releases/mozilla-beta", + "ssh": "ssh://hg.mozilla.org/releases/mozilla-beta", + }, + "user": "", + "valid": True, + }, + ), + ( + "https://hg.mozilla.org/releases/mozilla-release", + does_not_raise(), + { + "github": False, + "git_cinnabar": False, + "groups": [], + "hgmo": True, + "host": "hg.mozilla.org", + "name": "releases/mozilla-release", + "normalized": "https://hg.mozilla.org/releases/mozilla-release", + "path_raw": "", + "path": "", + "pathname": "/releases/mozilla-release", + "platform": "hgmo", + "port": "", + "protocol": "https", + "protocols": ["https"], + "repo": "releases/mozilla-release", + "repo_name": "mozilla-release", + "repo_path": "releases/mozilla-release", + "repo_type": "hg", + "resource": "hg.mozilla.org", + "taskcluster_role_prefix": "repo:hg.mozilla.org/releases/mozilla-release", # noqa: E501 + "urls": { + "hg": "hg://hg.mozilla.org:https/releases/mozilla-release", + "https": "https://hg.mozilla.org/releases/mozilla-release", + "ssh": "ssh://hg.mozilla.org/releases/mozilla-release", + }, + "user": "", + "valid": True, + }, + ), + ( + "https://hg.mozilla.org/try", + does_not_raise(), + { + "github": False, + "git_cinnabar": False, + "groups": [], + "hgmo": True, + "host": "hg.mozilla.org", + "name": "try", + "normalized": "https://hg.mozilla.org/try", + "path_raw": "", + "path": "", + "pathname": "/try", + "platform": "hgmo", + "port": "", + "protocol": "https", + "protocols": ["https"], + "repo": "try", + "repo_name": "try", + "repo_path": "try", + "repo_type": "hg", + "resource": "hg.mozilla.org", + "taskcluster_role_prefix": "repo:hg.mozilla.org/try", + "urls": { + "hg": "hg://hg.mozilla.org:https/try", + "https": "https://hg.mozilla.org/try", + "ssh": "ssh://hg.mozilla.org/try", + }, + "user": "", + "valid": True, + }, + ), + ( + "https://hg.mozilla.org/mozilla-central/raw-file/tip/taskcluster/ci/config.yml", # noqa: E501 + does_not_raise(), + { + "github": False, + "git_cinnabar": False, + "groups": [], + "hgmo": True, + "host": "hg.mozilla.org", + "name": "mozilla-central", + "normalized": "https://hg.mozilla.org/mozilla-central/raw-file/tip/taskcluster/ci/config.yml", # noqa: E501 + "path_raw": "/raw-file/tip/taskcluster/ci/config.yml", + "path": "tip/taskcluster/ci/config.yml", + "pathname": "/mozilla-central", + "platform": "hgmo", + "port": "", + "protocol": "https", + "protocols": ["https"], + "repo": "mozilla-central", + "repo_name": "mozilla-central", + "repo_path": "mozilla-central", + "repo_type": "hg", + "resource": "hg.mozilla.org", + "taskcluster_role_prefix": "repo:hg.mozilla.org/mozilla-central", + "urls": { + "hg": "hg://hg.mozilla.org:https/mozilla-central", + "https": "https://hg.mozilla.org/mozilla-central/raw-file/tip/taskcluster/ci/config.yml", # noqa: E501 + "ssh": "ssh://hg.mozilla.org/mozilla-central", + }, + "user": "", + "valid": True, + }, + ), + ( + "https://hg.mozilla.org/mozilla-central/file/tip/taskcluster/ci/config.yml", # noqa: E501 + does_not_raise(), + { + "github": False, + "git_cinnabar": False, + "groups": [], + "hgmo": True, + "host": "hg.mozilla.org", + "name": "mozilla-central", + "normalized": "https://hg.mozilla.org/mozilla-central/file/tip/taskcluster/ci/config.yml", # noqa: E501 + "path_raw": "/file/tip/taskcluster/ci/config.yml", + "path": "tip/taskcluster/ci/config.yml", + "pathname": "/mozilla-central", + "platform": "hgmo", + "port": "", + "protocol": "https", + "protocols": ["https"], + "repo": "mozilla-central", + "repo_name": "mozilla-central", + "repo_path": "mozilla-central", + "repo_type": "hg", + "resource": "hg.mozilla.org", + "taskcluster_role_prefix": "repo:hg.mozilla.org/mozilla-central", + "urls": { + "hg": "hg://hg.mozilla.org:https/mozilla-central", + "https": "https://hg.mozilla.org/mozilla-central/file/tip/taskcluster/ci/config.yml", # noqa: E501 + "ssh": "ssh://hg.mozilla.org/mozilla-central", + }, + "user": "", + "valid": True, + }, + ), + ( + "https://github.com/mozilla-mobile/fenix", + does_not_raise(), + { + "github": True, + "git_cinnabar": False, + "groups": [], + "hgmo": False, + "host": "github.com", + "name": "fenix", + "normalized": "https://github.com/mozilla-mobile/fenix.git", + "owner": "mozilla-mobile", + "path_raw": "", + "path": "", + "pathname": "/mozilla-mobile/fenix", + "platform": "github", + "port": "", + "protocol": "https", + "protocols": ["https"], + "repo": "fenix", + "repo_name": "fenix", + "repo_path": "mozilla-mobile/fenix", + "repo_type": "git", + "resource": "github.com", + "taskcluster_role_prefix": "repo:github.com/mozilla-mobile/fenix", + "urls": { + "git": "git://github.com/mozilla-mobile/fenix.git", + "https": "https://github.com/mozilla-mobile/fenix.git", + "ssh": "git@github.com:mozilla-mobile/fenix.git", + }, + "user": "git", + "valid": True, + }, + ), + ( + "git@github.com:mozilla-mobile/firefox-android.git", + does_not_raise(), + { + "github": True, + "git_cinnabar": False, + "groups": [], + "hgmo": False, + "host": "github.com", + "name": "firefox-android", + "normalized": "git@github.com:mozilla-mobile/firefox-android.git", + "owner": "mozilla-mobile", + "path_raw": "", + "path": "", + "pathname": "mozilla-mobile/firefox-android.git", + "platform": "github", + "port": "", + "protocol": "ssh", + "protocols": [], + "repo": "firefox-android", + "repo_name": "firefox-android", + "repo_path": "mozilla-mobile/firefox-android", + "repo_type": "git", + "resource": "github.com", + "taskcluster_role_prefix": "repo:github.com/mozilla-mobile/firefox-android", # noqa: E501 + "urls": { + "git": "git://github.com/mozilla-mobile/firefox-android.git", + "https": "https://github.com/mozilla-mobile/firefox-android.git", + "ssh": "git@github.com:mozilla-mobile/firefox-android.git", + }, + "user": "git", + "valid": True, + }, + ), + ( + "ssh://hg.mozilla.org/mozilla-unified", + does_not_raise(), + { + "github": False, + "groups": [], + "hgmo": True, + "host": "hg.mozilla.org", + "name": "mozilla-unified", + "normalized": "ssh://hg.mozilla.org/mozilla-unified", + "path_raw": "", + "path": "", + "pathname": "/mozilla-unified", + "platform": "hgmo", + "port": "", + "protocol": "ssh", + "protocols": ["ssh"], + "repo": "mozilla-unified", + "repo_name": "mozilla-unified", + "repo_path": "mozilla-unified", + "repo_type": "hg", + "resource": "hg.mozilla.org", + "taskcluster_role_prefix": "repo:hg.mozilla.org/mozilla-unified", + "urls": { + "hg": "hg://hg.mozilla.org:ssh/mozilla-unified", + "https": "https://hg.mozilla.org/mozilla-unified", + "ssh": "ssh://hg.mozilla.org/mozilla-unified", + }, + "user": "", + "valid": True, + }, + ), + ( + "hg::https://hg.mozilla.org/mozilla-unified", + does_not_raise(), + { + "github": False, + "git_cinnabar": True, + "groups": [], + "hgmo": True, + "host": "hg.mozilla.org", + "name": "mozilla-unified", + "normalized": "https://hg.mozilla.org/mozilla-unified", + "path_raw": "", + "path": "", + "pathname": "/mozilla-unified", + "platform": "hgmo", + "port": "", + "protocol": "https", + "protocols": ["hg::https"], + "repo": "mozilla-unified", + "repo_name": "mozilla-unified", + "repo_path": "mozilla-unified", + "repo_type": "git", + "resource": "hg.mozilla.org", + "taskcluster_role_prefix": "repo:hg.mozilla.org/mozilla-unified", + "urls": { + "hg": "hg://hg.mozilla.org:https/mozilla-unified", + "https": "https://hg.mozilla.org/mozilla-unified", + "ssh": "ssh://hg.mozilla.org/mozilla-unified", + }, + "user": "", + "valid": True, + }, + ), + ( + "hg::ssh://hg.mozilla.org/mozilla-unified", + does_not_raise(), + { + "github": False, + "git_cinnabar": True, + "groups": [], + "hgmo": True, + "host": "hg.mozilla.org", + "name": "mozilla-unified", + "normalized": "ssh://hg.mozilla.org/mozilla-unified", + "path_raw": "", + "path": "", + "pathname": "/mozilla-unified", + "platform": "hgmo", + "port": "", + "protocol": "ssh", + "protocols": ["hg::ssh"], + "repo": "mozilla-unified", + "repo_name": "mozilla-unified", + "repo_path": "mozilla-unified", + "repo_type": "git", + "resource": "hg.mozilla.org", + "taskcluster_role_prefix": "repo:hg.mozilla.org/mozilla-unified", + "urls": { + "hg": "hg://hg.mozilla.org:ssh/mozilla-unified", + "https": "https://hg.mozilla.org/mozilla-unified", + "ssh": "ssh://hg.mozilla.org/mozilla-unified", + }, + "user": "", + "valid": True, + }, + ), + ( + "hg://hg.mozilla.org/mozilla-central", + does_not_raise(), + { + "github": False, + "git_cinnabar": True, + "groups": [], + "hgmo": True, + "host": "hg.mozilla.org", + "name": "mozilla-central", + "normalized": "hg://hg.mozilla.org:https/mozilla-central", + "path_raw": "", + "path": "", + "pathname": "/mozilla-central", + "platform": "hgmo", + "port": "", + "protocol": "hg", + "protocols": ["hg::https"], + "repo": "mozilla-central", + "repo_name": "mozilla-central", + "repo_path": "mozilla-central", + "repo_type": "git", + "resource": "hg.mozilla.org", + "taskcluster_role_prefix": "repo:hg.mozilla.org/mozilla-central", + "urls": { + "hg": "hg://hg.mozilla.org:https/mozilla-central", + "https": "https://hg.mozilla.org/mozilla-central", + "ssh": "ssh://hg.mozilla.org/mozilla-central", + }, + "user": "", + "valid": True, + }, + ), + ( + "hg://hg.mozilla.org:https/mozilla-central", + does_not_raise(), + { + "github": False, + "git_cinnabar": True, + "groups": [], + "hgmo": True, + "host": "hg.mozilla.org", + "name": "mozilla-central", + "normalized": "hg://hg.mozilla.org:https/mozilla-central", + "path_raw": "", + "path": "", + "pathname": "/mozilla-central", + "platform": "hgmo", + "port": "", + "protocol": "hg", + "protocols": ["hg::https"], + "repo": "mozilla-central", + "repo_name": "mozilla-central", + "repo_path": "mozilla-central", + "repo_type": "git", + "resource": "hg.mozilla.org", + "taskcluster_role_prefix": "repo:hg.mozilla.org/mozilla-central", + "urls": { + "hg": "hg://hg.mozilla.org:https/mozilla-central", + "https": "https://hg.mozilla.org/mozilla-central", + "ssh": "ssh://hg.mozilla.org/mozilla-central", + }, + "user": "", + "valid": True, + }, + ), + ( + "hg://hg.mozilla.org:ssh/mozilla-central", + does_not_raise(), + { + "github": False, + "git_cinnabar": True, + "groups": [], + "hgmo": True, + "host": "hg.mozilla.org", + "name": "mozilla-central", + "normalized": "hg://hg.mozilla.org:ssh/mozilla-central", + "path_raw": "", + "path": "", + "pathname": "/mozilla-central", + "platform": "hgmo", + "port": "", + "protocol": "hg", + "protocols": ["hg::ssh"], + "repo": "mozilla-central", + "repo_name": "mozilla-central", + "repo_path": "mozilla-central", + "repo_type": "git", + "resource": "hg.mozilla.org", + "taskcluster_role_prefix": "repo:hg.mozilla.org/mozilla-central", + "urls": { + "hg": "hg://hg.mozilla.org:ssh/mozilla-central", + "https": "https://hg.mozilla.org/mozilla-central", + "ssh": "ssh://hg.mozilla.org/mozilla-central", + }, + "user": "", + "valid": True, + }, + ), + ( + "https://some.unknown/repo", + pytest.raises(mozilla_repo_urls.InvalidRepoUrlError), + None, + ), + ( + "https://gitlab.com/some-owner/some-repo", + pytest.raises(mozilla_repo_urls.UnsupportedPlatformError), + None, + ), + ), +) +def test_parse(url_string, expectation, expected): + with expectation: + url_object = mozilla_repo_urls.parse(url_string) + actual = { + attribute_name: getattr(url_object, attribute_name) + for attribute_name in expected.keys() + } + assert actual == expected diff --git a/third_party/python/mozilla_repo_urls/test/test_parser.py b/third_party/python/mozilla_repo_urls/test/test_parser.py new file mode 100644 index 0000000000..2c517395f7 --- /dev/null +++ b/third_party/python/mozilla_repo_urls/test/test_parser.py @@ -0,0 +1,9 @@ +from mozilla_repo_urls import parser + + +def test_supported_hosts(): + assert parser.SUPPORTED_HOSTS == ( + "gist.github.com", + "github.com", + "hg.mozilla.org", + ) |