Skip to content

Commit

Permalink
tests: verify PEP 610 compliance for vcs urls (#9007)
Browse files Browse the repository at this point in the history
  • Loading branch information
abn authored Oct 6, 2024
1 parent 09d2e50 commit 6bca8f9
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions tests/installation/test_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -939,6 +939,13 @@ def mock_get_cached_archive_func(
download_spy.assert_not_called()


@pytest.mark.parametrize(
"source_url,written_source_url",
[
("https://github.com/demo/demo.git", "https://github.com/demo/demo.git"),
("[email protected]:demo/demo.git", "ssh://[email protected]/demo/demo.git"),
],
)
@pytest.mark.parametrize("is_artifact_cached", [False, True])
def test_executor_should_write_pep610_url_references_for_git(
tmp_venv: VirtualEnv,
Expand All @@ -949,6 +956,8 @@ def test_executor_should_write_pep610_url_references_for_git(
wheel: Path,
mocker: MockerFixture,
fixture_dir: FixtureDirGetter,
source_url: str,
written_source_url: str,
is_artifact_cached: bool,
) -> None:
if is_artifact_cached:
Expand All @@ -960,7 +969,7 @@ def test_executor_should_write_pep610_url_references_for_git(
clone_spy = mocker.spy(Git, "clone")

source_resolved_reference = "123456"
source_url = "https://github.com/demo/demo.git"
source_url = source_url

package = Package(
"demo",
Expand All @@ -971,6 +980,8 @@ def test_executor_should_write_pep610_url_references_for_git(
source_url=source_url,
)

assert package.source_url == written_source_url

chef = Chef(artifact_cache, tmp_venv, Factory.create_pool(config))
chef.set_directory_wheel(wheel)
prepare_spy = mocker.spy(chef, "prepare")
Expand All @@ -996,7 +1007,9 @@ def test_executor_should_write_pep610_url_references_for_git(
prepare_spy.assert_not_called()
else:
clone_spy.assert_called_once_with(
url=source_url, source_root=mocker.ANY, revision=source_resolved_reference
url=package.source_url,
source_root=mocker.ANY,
revision=source_resolved_reference,
)
prepare_spy.assert_called_once()
assert prepare_spy.spy_return.exists(), "cached file should not be deleted"
Expand Down

0 comments on commit 6bca8f9

Please sign in to comment.