-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Runtime Environment] Parse special characters in private Git URIs (#…
- Loading branch information
1 parent
9bfc2e9
commit 943175a
Showing
2 changed files
with
47 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -373,6 +373,49 @@ def test_unzip_with_matching_subdirectory_names( | |
) | ||
|
||
|
||
class TestParseUri: | ||
@pytest.mark.parametrize( | ||
"parsing_tuple", | ||
[ | ||
("gcs://file.zip", Protocol.GCS, "file.zip"), | ||
("s3://bucket/file.zip", Protocol.S3, "s3_bucket_file.zip"), | ||
("https://test.com/file.zip", Protocol.HTTPS, "https_test_com_file.zip"), | ||
("gs://bucket/file.zip", Protocol.GS, "gs_bucket_file.zip"), | ||
], | ||
) | ||
def test_parsing_basic(self, parsing_tuple): | ||
uri, protocol, package_name = parsing_tuple | ||
parsed_protocol, parsed_package_name = parse_uri(uri) | ||
|
||
assert protocol == parsed_protocol | ||
assert package_name == parsed_package_name | ||
|
||
@pytest.mark.parametrize( | ||
"parsing_tuple", | ||
[ | ||
( | ||
"https://username:[email protected]/repo/archive/commit_hash.zip", | ||
"https_username_PAT_github_com_repo_archive_commit_hash.zip", | ||
), | ||
( | ||
( | ||
"https://un:[email protected]/user/repo/-/" | ||
"archive/commit_hash/repo-commit_hash.zip" | ||
), | ||
( | ||
"https_un_pwd_gitlab_com_user_repo_-_" | ||
"archive_commit_hash_repo-commit_hash.zip" | ||
), | ||
), | ||
], | ||
) | ||
def test_parse_private_git_https_uris(self, parsing_tuple): | ||
raw_uri, parsed_uri = parsing_tuple | ||
parsed_protocol, parsed_package_name = parse_uri(raw_uri) | ||
assert parsed_protocol == Protocol.HTTPS | ||
assert parsed_package_name == parsed_uri | ||
|
||
|
||
@pytest.mark.skipif(sys.platform == "win32", reason="Fails on windows") | ||
def test_travel(tmp_path): | ||
dir_paths = set() | ||
|
@@ -433,23 +476,6 @@ def handler(path): | |
assert dir_paths == visited_dir_paths | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"parsing_tuple", | ||
[ | ||
("gcs://file.zip", Protocol.GCS, "file.zip"), | ||
("s3://bucket/file.zip", Protocol.S3, "s3_bucket_file.zip"), | ||
("https://test.com/file.zip", Protocol.HTTPS, "https_test_com_file.zip"), | ||
("gs://bucket/file.zip", Protocol.GS, "gs_bucket_file.zip"), | ||
], | ||
) | ||
def test_parsing(parsing_tuple): | ||
uri, protocol, package_name = parsing_tuple | ||
parsed_protocol, parsed_package_name = parse_uri(uri) | ||
|
||
assert protocol == parsed_protocol | ||
assert package_name == parsed_package_name | ||
|
||
|
||
def test_is_whl_uri(): | ||
assert is_whl_uri("gcs://my-package.whl") | ||
assert not is_whl_uri("gcs://asdf.zip") | ||
|