mirror of
https://github.com/enpaul/tox-poetry-installer.git
synced 2025-01-15 08:43:29 +00:00
Fix tests to use new packagemap type and data structure
This commit is contained in:
parent
ff3e1603d2
commit
45e33b7d27
@ -31,6 +31,10 @@ class MockVirtualEnv:
|
|||||||
def is_valid_for_marker(*args, **kwargs):
|
def is_valid_for_marker(*args, **kwargs):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_version_info():
|
||||||
|
return (1, 2, 3)
|
||||||
|
|
||||||
|
|
||||||
class MockPipInstaller:
|
class MockPipInstaller:
|
||||||
"""Mock class for the :class:`poetry.installation.pip_installer.PipInstaller`"""
|
"""Mock class for the :class:`poetry.installation.pip_installer.PipInstaller`"""
|
||||||
|
@ -6,14 +6,14 @@ from poetry.factory import Factory
|
|||||||
|
|
||||||
from .fixtures import mock_poetry_factory
|
from .fixtures import mock_poetry_factory
|
||||||
from .fixtures import mock_venv
|
from .fixtures import mock_venv
|
||||||
from tox_poetry_installer import datatypes
|
|
||||||
from tox_poetry_installer import installer
|
from tox_poetry_installer import installer
|
||||||
|
from tox_poetry_installer import utilities
|
||||||
|
|
||||||
|
|
||||||
def test_deduplication(mock_venv, mock_poetry_factory):
|
def test_deduplication(mock_venv, mock_poetry_factory):
|
||||||
"""Test that the installer does not install duplicate dependencies"""
|
"""Test that the installer does not install duplicate dependencies"""
|
||||||
poetry = Factory().create_poetry(None)
|
poetry = Factory().create_poetry(None)
|
||||||
packages: datatypes.PackageMap = {
|
packages: utilities.PackageMap = {
|
||||||
item.name: item for item in poetry.locker.locked_repository(False).packages
|
item.name: item for item in poetry.locker.locked_repository(False).packages
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ def test_deduplication(mock_venv, mock_poetry_factory):
|
|||||||
def test_parallelization(mock_venv, mock_poetry_factory):
|
def test_parallelization(mock_venv, mock_poetry_factory):
|
||||||
"""Test that behavior is consistent between parallel and non-parallel usage"""
|
"""Test that behavior is consistent between parallel and non-parallel usage"""
|
||||||
poetry = Factory().create_poetry(None)
|
poetry = Factory().create_poetry(None)
|
||||||
packages: datatypes.PackageMap = {
|
packages: utilities.PackageMap = {
|
||||||
item.name: item for item in poetry.locker.locked_repository(False).packages
|
item.name: item for item in poetry.locker.locked_repository(False).packages
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@ from poetry.puzzle.provider import Provider
|
|||||||
from .fixtures import mock_poetry_factory
|
from .fixtures import mock_poetry_factory
|
||||||
from .fixtures import mock_venv
|
from .fixtures import mock_venv
|
||||||
from tox_poetry_installer import constants
|
from tox_poetry_installer import constants
|
||||||
from tox_poetry_installer import datatypes
|
|
||||||
from tox_poetry_installer import exceptions
|
from tox_poetry_installer import exceptions
|
||||||
from tox_poetry_installer import utilities
|
from tox_poetry_installer import utilities
|
||||||
|
|
||||||
@ -58,17 +57,15 @@ def test_functional(mock_poetry_factory, mock_venv):
|
|||||||
is always the last in the returned list.
|
is always the last in the returned list.
|
||||||
"""
|
"""
|
||||||
pypoetry = poetry.factory.Factory().create_poetry(None)
|
pypoetry = poetry.factory.Factory().create_poetry(None)
|
||||||
packages: datatypes.PackageMap = {
|
packages = utilities.build_package_map(pypoetry)
|
||||||
item.name: item for item in pypoetry.locker.locked_repository(False).packages
|
|
||||||
}
|
|
||||||
venv = poetry.utils.env.VirtualEnv() # pylint: disable=no-value-for-parameter
|
venv = poetry.utils.env.VirtualEnv() # pylint: disable=no-value-for-parameter
|
||||||
|
|
||||||
requests_requires = [
|
requests_requires = [
|
||||||
packages["certifi"],
|
packages["certifi"][0],
|
||||||
packages["chardet"],
|
packages["chardet"][0],
|
||||||
packages["idna"],
|
packages["idna"][0],
|
||||||
packages["urllib3"],
|
packages["urllib3"][0],
|
||||||
packages["requests"],
|
packages["requests"][0],
|
||||||
]
|
]
|
||||||
|
|
||||||
transients = utilities.identify_transients("requests", packages, venv)
|
transients = utilities.identify_transients("requests", packages, venv)
|
||||||
@ -76,7 +73,7 @@ def test_functional(mock_poetry_factory, mock_venv):
|
|||||||
assert all((item in requests_requires) for item in transients)
|
assert all((item in requests_requires) for item in transients)
|
||||||
assert all((item in transients) for item in requests_requires)
|
assert all((item in transients) for item in requests_requires)
|
||||||
|
|
||||||
for package in [packages["requests"], packages["tox"], packages["flask"]]:
|
for package in [packages["requests"][0], packages["tox"][0], packages["flask"][0]]:
|
||||||
transients = utilities.identify_transients(package, packages, venv)
|
transients = utilities.identify_transients(package.name, packages, venv)
|
||||||
assert transients[-1] == package
|
assert transients[-1] == package
|
||||||
assert len(transients) == len(set(transients))
|
assert len(transients) == len(set(transients))
|
||||||
|
Loading…
Reference in New Issue
Block a user