forked from python-poetry/poetry
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_sync.py
More file actions
45 lines (28 loc) · 1.27 KB
/
test_sync.py
File metadata and controls
45 lines (28 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from __future__ import annotations
from typing import TYPE_CHECKING
import pytest
from cleo.exceptions import CleoNoSuchOptionError
from poetry.console.commands.sync import SyncCommand
# import all tests from the install command
# and run them for sync by overriding the command fixture
from tests.console.commands.test_install import * # noqa: F403
if TYPE_CHECKING:
from cleo.testers.command_tester import CommandTester
from pytest_mock import MockerFixture
@pytest.fixture # type: ignore[no-redef]
def command() -> str:
return "sync"
@pytest.mark.skip("Only relevant for `poetry install`") # type: ignore[no-redef]
def test_sync_option_is_passed_to_the_installer() -> None:
"""The only test from the install command that does not work for sync."""
def test_sync_option_not_available(tester: CommandTester) -> None:
with pytest.raises(CleoNoSuchOptionError):
tester.execute("--sync")
def test_synced_installer(tester: CommandTester, mocker: MockerFixture) -> None:
assert isinstance(tester.command, SyncCommand)
mock = mocker.patch(
"poetry.console.commands.install.InstallCommand.installer",
new_callable=mocker.PropertyMock,
)
tester.execute()
mock.return_value.requires_synchronization.assert_called_with(True)