Commit 6ae844bc by David Hotham Committed by Bjorn Neergaard

respect --no-cache at poetry install

parent 60168d68
......@@ -327,6 +327,7 @@ class Application(BaseApplication): # type: ignore[misc]
poetry.locker,
poetry.pool,
poetry.config,
disable_cache=poetry.disable_cache,
)
installer.use_executor(poetry.config.get("experimental.new-installer", False))
command.set_installer(installer)
......
......@@ -92,6 +92,7 @@ class Factory(BaseFactory):
base_poetry.package,
locker,
config,
disable_cache,
)
# Configuring sources
......
......@@ -53,13 +53,16 @@ class Executor:
config: Config,
io: IO,
parallel: bool | None = None,
disable_cache: bool = False,
) -> None:
self._env = env
self._io = io
self._dry_run = False
self._enabled = True
self._verbose = False
self._authenticator = Authenticator(config, self._io)
self._authenticator = Authenticator(
config, self._io, disable_cache=disable_cache
)
self._chef = Chef(config, self._env)
self._chooser = Chooser(pool, self._env, config)
......
......@@ -43,6 +43,7 @@ class Installer:
config: Config,
installed: Repository | None = None,
executor: Executor | None = None,
disable_cache: bool = False,
) -> None:
self._io = io
self._env = env
......@@ -65,7 +66,9 @@ class Installer:
self._extras: list[str] = []
if executor is None:
executor = Executor(self._env, self._pool, config, self._io)
executor = Executor(
self._env, self._pool, config, self._io, disable_cache=disable_cache
)
self._executor = executor
self._use_executor = False
......
......@@ -30,6 +30,7 @@ class Poetry(BasePoetry):
package: ProjectPackage,
locker: Locker,
config: Config,
disable_cache: bool = False,
) -> None:
from poetry.repositories.pool import Pool
......@@ -39,6 +40,7 @@ class Poetry(BasePoetry):
self._config = config
self._pool = Pool()
self._plugin_manager: PluginManager | None = None
self._disable_cache = disable_cache
@property
def locker(self) -> Locker:
......@@ -52,6 +54,10 @@ class Poetry(BasePoetry):
def config(self) -> Config:
return self._config
@property
def disable_cache(self) -> bool:
return self._disable_cache
def set_locker(self, locker: Locker) -> Poetry:
self._locker = locker
......
......@@ -11,6 +11,7 @@ from cleo.testers.application_tester import ApplicationTester
from poetry.console.application import Application
from poetry.console.commands.command import Command
from poetry.plugins.application_plugin import ApplicationPlugin
from poetry.utils.authenticator import Authenticator
from tests.helpers import mock_metadata_entry_points
......@@ -99,3 +100,26 @@ def test_application_verify_source_cache_flag(disable_cache: bool):
for repo in app.poetry.pool.repositories:
assert repo._disable_cache == disable_cache
@pytest.mark.parametrize("disable_cache", [True, False])
def test_application_verify_cache_flag_at_install(
mocker: MockerFixture, disable_cache: bool
) -> None:
app = Application()
tester = ApplicationTester(app)
command = "install --dry-run"
if disable_cache:
command = f"{command} --no-cache"
spy = mocker.spy(Authenticator, "__init__")
tester.execute(command)
assert spy.call_count == 2
for call in spy.mock_calls:
(name, args, kwargs) = call
assert "disable_cache" in kwargs
assert disable_cache is kwargs["disable_cache"]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment