"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tests/installation/test_chef.py" between
poetry-1.1.15.tar.gz and poetry-1.2.0.tar.gz

About: Poetry is a tool for dependency management and packaging in Python.

test_chef.py  (poetry-1.1.15):test_chef.py  (poetry-1.2.0)
from packaging.tags import Tag from __future__ import annotations
from pathlib import Path
from typing import TYPE_CHECKING
import pytest
from packaging.tags import Tag
from poetry.core.packages.utils.link import Link from poetry.core.packages.utils.link import Link
from poetry.installation.chef import Chef from poetry.installation.chef import Chef
from poetry.utils._compat import Path
from poetry.utils.env import MockEnv from poetry.utils.env import MockEnv
def test_get_cached_archive_for_link(config, mocker): if TYPE_CHECKING:
from pytest_mock import MockerFixture
from tests.conftest import Config
@pytest.mark.parametrize(
("link", "cached"),
[
(
"https://files.python-poetry.org/demo-0.1.0.tar.gz",
"/cache/demo-0.1.0-cp38-cp38-macosx_10_15_x86_64.whl",
),
(
"https://example.com/demo-0.1.0-cp38-cp38-macosx_10_15_x86_64.whl",
"/cache/demo-0.1.0-cp38-cp38-macosx_10_15_x86_64.whl",
),
],
)
def test_get_cached_archive_for_link(
config: Config, mocker: MockerFixture, link: str, cached: str
):
chef = Chef( chef = Chef(
config, config,
MockEnv( MockEnv(
version_info=(3, 8, 3), version_info=(3, 8, 3),
marker_env={"interpreter_name": "cpython", "interpreter_version": "3 .8.3"}, marker_env={"interpreter_name": "cpython", "interpreter_version": "3 .8.3"},
supported_tags=[ supported_tags=[
Tag("cp38", "cp38", "macosx_10_15_x86_64"), Tag("cp38", "cp38", "macosx_10_15_x86_64"),
Tag("py3", "none", "any"), Tag("py3", "none", "any"),
], ],
), ),
) )
mocker.patch.object( mocker.patch.object(
chef, chef,
"get_cached_archives_for_link", "get_cached_archives_for_link",
return_value=[ return_value=[
Link("file:///foo/demo-0.1.0-py2.py3-none-any"), Path("/cache/demo-0.1.0-py2.py3-none-any"),
Link("file:///foo/demo-0.1.0.tar.gz"), Path("/cache/demo-0.1.0.tar.gz"),
Link("file:///foo/demo-0.1.0-cp38-cp38-macosx_10_15_x86_64.whl"), Path("/cache/demo-0.1.0-cp38-cp38-macosx_10_15_x86_64.whl"),
Link("file:///foo/demo-0.1.0-cp37-cp37-macosx_10_15_x86_64.whl"), Path("/cache/demo-0.1.0-cp37-cp37-macosx_10_15_x86_64.whl"),
], ],
) )
archive = chef.get_cached_archive_for_link( archive = chef.get_cached_archive_for_link(Link(link))
Link("https://files.python-poetry.org/demo-0.1.0.tar.gz")
)
assert Link("file:///foo/demo-0.1.0-cp38-cp38-macosx_10_15_x86_64.whl") == a rchive assert Path(cached) == archive
def test_get_cached_archives_for_link(config, mocker): def test_get_cached_archives_for_link(config: Config, mocker: MockerFixture):
chef = Chef( chef = Chef(
config, config,
MockEnv( MockEnv(
marker_env={"interpreter_name": "cpython", "interpreter_version": "3 .8.3"} marker_env={"interpreter_name": "cpython", "interpreter_version": "3 .8.3"}
), ),
) )
distributions = Path(__file__).parent.parent.joinpath("fixtures/distribution s") distributions = Path(__file__).parent.parent.joinpath("fixtures/distribution s")
mocker.patch.object( mocker.patch.object(
chef, "get_cache_directory_for_link", return_value=distributions, chef,
"get_cache_directory_for_link",
return_value=distributions,
) )
archives = chef.get_cached_archives_for_link( archives = chef.get_cached_archives_for_link(
Link("https://files.python-poetry.org/demo-0.1.0.tar.gz") Link("https://files.python-poetry.org/demo-0.1.0.tar.gz")
) )
assert archives assert archives
assert set(archives) == { assert set(archives) == {Path(path) for path in distributions.glob("demo-0.1
Link(path.as_uri()) for path in distributions.glob("demo-0.1.0*") .0*")}
}
def test_get_cache_directory_for_link(config): def test_get_cache_directory_for_link(config: Config, config_cache_dir: Path):
chef = Chef( chef = Chef(
config, config,
MockEnv( MockEnv(
marker_env={"interpreter_name": "cpython", "interpreter_version": "3 .8.3"} marker_env={"interpreter_name": "cpython", "interpreter_version": "3 .8.3"}
), ),
) )
directory = chef.get_cache_directory_for_link( directory = chef.get_cache_directory_for_link(
Link("https://files.python-poetry.org/poetry-1.1.0.tar.gz") Link("https://files.python-poetry.org/poetry-1.1.0.tar.gz")
) )
expected = Path( expected = Path(
"/foo/artifacts/ba/63/13/283a3b3b7f95f05e9e6f84182d276f7bb0951d5b0cc2442 f"{config_cache_dir.as_posix()}/artifacts/ba/63/13/"
2b33f7a4648" "283a3b3b7f95f05e9e6f84182d276f7bb0951d5b0cc24422b33f7a4648"
) )
assert expected == directory assert directory == expected
 End of changes. 15 change blocks. 
19 lines changed or deleted 45 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)