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] ...@@ -327,6 +327,7 @@ class Application(BaseApplication): # type: ignore[misc]
poetry.locker, poetry.locker,
poetry.pool, poetry.pool,
poetry.config, poetry.config,
disable_cache=poetry.disable_cache,
) )
installer.use_executor(poetry.config.get("experimental.new-installer", False)) installer.use_executor(poetry.config.get("experimental.new-installer", False))
command.set_installer(installer) command.set_installer(installer)
......
...@@ -92,6 +92,7 @@ class Factory(BaseFactory): ...@@ -92,6 +92,7 @@ class Factory(BaseFactory):
base_poetry.package, base_poetry.package,
locker, locker,
config, config,
disable_cache,
) )
# Configuring sources # Configuring sources
......
...@@ -53,13 +53,16 @@ class Executor: ...@@ -53,13 +53,16 @@ class Executor:
config: Config, config: Config,
io: IO, io: IO,
parallel: bool | None = None, parallel: bool | None = None,
disable_cache: bool = False,
) -> None: ) -> None:
self._env = env self._env = env
self._io = io self._io = io
self._dry_run = False self._dry_run = False
self._enabled = True self._enabled = True
self._verbose = False 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._chef = Chef(config, self._env)
self._chooser = Chooser(pool, self._env, config) self._chooser = Chooser(pool, self._env, config)
......
...@@ -43,6 +43,7 @@ class Installer: ...@@ -43,6 +43,7 @@ class Installer:
config: Config, config: Config,
installed: Repository | None = None, installed: Repository | None = None,
executor: Executor | None = None, executor: Executor | None = None,
disable_cache: bool = False,
) -> None: ) -> None:
self._io = io self._io = io
self._env = env self._env = env
...@@ -65,7 +66,9 @@ class Installer: ...@@ -65,7 +66,9 @@ class Installer:
self._extras: list[str] = [] self._extras: list[str] = []
if executor is None: 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._executor = executor
self._use_executor = False self._use_executor = False
......
...@@ -30,6 +30,7 @@ class Poetry(BasePoetry): ...@@ -30,6 +30,7 @@ class Poetry(BasePoetry):
package: ProjectPackage, package: ProjectPackage,
locker: Locker, locker: Locker,
config: Config, config: Config,
disable_cache: bool = False,
) -> None: ) -> None:
from poetry.repositories.pool import Pool from poetry.repositories.pool import Pool
...@@ -39,6 +40,7 @@ class Poetry(BasePoetry): ...@@ -39,6 +40,7 @@ class Poetry(BasePoetry):
self._config = config self._config = config
self._pool = Pool() self._pool = Pool()
self._plugin_manager: PluginManager | None = None self._plugin_manager: PluginManager | None = None
self._disable_cache = disable_cache
@property @property
def locker(self) -> Locker: def locker(self) -> Locker:
...@@ -52,6 +54,10 @@ class Poetry(BasePoetry): ...@@ -52,6 +54,10 @@ class Poetry(BasePoetry):
def config(self) -> Config: def config(self) -> Config:
return self._config return self._config
@property
def disable_cache(self) -> bool:
return self._disable_cache
def set_locker(self, locker: Locker) -> Poetry: def set_locker(self, locker: Locker) -> Poetry:
self._locker = locker self._locker = locker
......
...@@ -11,6 +11,7 @@ from cleo.testers.application_tester import ApplicationTester ...@@ -11,6 +11,7 @@ from cleo.testers.application_tester import ApplicationTester
from poetry.console.application import Application from poetry.console.application import Application
from poetry.console.commands.command import Command from poetry.console.commands.command import Command
from poetry.plugins.application_plugin import ApplicationPlugin from poetry.plugins.application_plugin import ApplicationPlugin
from poetry.utils.authenticator import Authenticator
from tests.helpers import mock_metadata_entry_points from tests.helpers import mock_metadata_entry_points
...@@ -99,3 +100,26 @@ def test_application_verify_source_cache_flag(disable_cache: bool): ...@@ -99,3 +100,26 @@ def test_application_verify_source_cache_flag(disable_cache: bool):
for repo in app.poetry.pool.repositories: for repo in app.poetry.pool.repositories:
assert repo._disable_cache == disable_cache 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