Skip to content

Commit ec623e6

Browse files
committed
Remove Manual Installation + Testing
1 parent e77e21e commit ec623e6

File tree

2 files changed

+3
-128
lines changed

2 files changed

+3
-128
lines changed

cppython/plugins/conan/plugin.py

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -69,40 +69,7 @@ def information() -> Information:
6969
"""
7070
return Information()
7171

72-
def _install_dependencies(self, *, update: bool = False) -> None:
73-
"""Install/update dependencies using Conan API.
74-
75-
Args:
76-
update: If True, check remotes for newer versions/revisions and install those.
77-
If False, use cached versions when available.
78-
"""
79-
operation = 'update' if update else 'install'
80-
81-
try:
82-
# Setup environment and generate conanfile
83-
conan_api, conanfile_path = self._prepare_installation()
84-
except Exception as e:
85-
raise ProviderInstallationError('conan', f'Failed to prepare {operation} environment: {e}', e) from e
86-
87-
try:
88-
# Load dependency graph
89-
deps_graph = self._load_dependency_graph(conan_api, conanfile_path, update)
90-
except Exception as e:
91-
raise ProviderInstallationError('conan', f'Failed to load dependency graph: {e}', e) from e
92-
93-
try:
94-
# Install dependencies
95-
self._install_binaries(conan_api, deps_graph, update)
96-
except Exception as e:
97-
raise ProviderInstallationError('conan', f'Failed to install binary dependencies: {e}', e) from e
98-
99-
try:
100-
# Generate consumer files
101-
self._generate_consumer_files(conan_api, deps_graph)
102-
except Exception as e:
103-
raise ProviderInstallationError('conan', f'Failed to generate consumer files: {e}', e) from e
104-
105-
def _prepare_installation(self) -> tuple[ConanAPI, Path]:
72+
def _setup_environment(self) -> tuple[ConanAPI, Path]:
10673
"""Prepare the installation environment and generate conanfile.
10774
10875
Returns:
@@ -199,11 +166,11 @@ def _generate_consumer_files(self, conan_api: ConanAPI, deps_graph) -> None:
199166

200167
def install(self) -> None:
201168
"""Installs the provider"""
202-
self._install_dependencies(update=False)
169+
self._setup_environment()
203170

204171
def update(self) -> None:
205172
"""Updates the provider"""
206-
self._install_dependencies(update=True)
173+
self._setup_environment()
207174

208175
@staticmethod
209176
def supported_sync_type(sync_type: type[SyncData]) -> bool:

tests/unit/plugins/conan/test_install.py

Lines changed: 0 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,9 @@
66

77
import pytest
88
from packaging.requirements import Requirement
9-
from pytest_mock import MockerFixture
109

1110
from cppython.plugins.conan.plugin import ConanProvider
12-
from cppython.plugins.conan.schema import ConanDependency
1311
from cppython.test.pytest.mixins import ProviderPluginTestMixin
14-
from cppython.utility.exception import ProviderInstallationError
1512

1613
# Constants for test assertions
1714
EXPECTED_PROFILE_CALLS = 2
@@ -81,92 +78,3 @@ def test_with_dependencies(
8178

8279
# Verify build path was created
8380
assert plugin.core_data.cppython_data.build_path.exists()
84-
85-
# Verify ConanAPI constructor was called
86-
conan_setup_mocks['conan_api_constructor'].assert_called_once()
87-
88-
def test_conan_command_failure(
89-
self,
90-
plugin: ConanProvider,
91-
conan_temp_conanfile: Path,
92-
conan_mock_dependencies: list[Requirement],
93-
conan_mock_api: Mock,
94-
mocker: MockerFixture,
95-
) -> None:
96-
"""Test install method when conan API operations fail
97-
98-
Args:
99-
plugin: The plugin instance
100-
conan_temp_conanfile: Path to temporary conanfile.py
101-
conan_mock_dependencies: List of mock dependencies
102-
conan_mock_api: Mock ConanAPI instance
103-
mocker: Pytest mocker fixture
104-
"""
105-
# Mock builder
106-
mock_builder = mocker.Mock()
107-
mock_builder.generate_conanfile = mocker.Mock()
108-
plugin.builder = mock_builder # type: ignore[attr-defined]
109-
110-
# Configure the API mock to fail on graph loading
111-
conan_mock_api.graph.load_graph_consumer.side_effect = Exception('Conan API error: package not found')
112-
113-
# Mock ConanAPI constructor to return our configured mock
114-
mock_conan_api_constructor = mocker.patch('cppython.plugins.conan.plugin.ConanAPI', return_value=conan_mock_api)
115-
116-
# Mock resolve_conan_dependency
117-
def mock_resolve(requirement: Requirement) -> ConanDependency:
118-
return ConanDependency(name=requirement.name)
119-
120-
mocker.patch('cppython.plugins.conan.plugin.resolve_conan_dependency', side_effect=mock_resolve)
121-
122-
# Add a dependency
123-
plugin.core_data.cppython_data.dependencies = [conan_mock_dependencies[0]]
124-
125-
# Execute and verify exception is raised
126-
with pytest.raises(
127-
ProviderInstallationError,
128-
match='Failed to load dependency graph: Conan API error: package not found',
129-
):
130-
plugin.install()
131-
132-
# Verify builder was still called
133-
mock_builder.generate_conanfile.assert_called_once()
134-
135-
# Verify Conan API was attempted
136-
mock_conan_api_constructor.assert_called_once()
137-
138-
def test_with_default_profiles(
139-
self,
140-
plugin: ConanProvider,
141-
conan_temp_conanfile: Path,
142-
conan_mock_dependencies: list[Requirement],
143-
conan_setup_mocks: dict[str, Mock],
144-
conan_mock_api: Mock,
145-
) -> None:
146-
"""Test install method uses pre-resolved profiles from plugin construction
147-
148-
Args:
149-
plugin: The plugin instance
150-
conan_temp_conanfile: Path to temporary conanfile.py
151-
conan_mock_dependencies: List of mock dependencies
152-
conan_setup_mocks: Dictionary containing all mocks
153-
conan_mock_api: Mock ConanAPI instance
154-
"""
155-
# Setup dependencies
156-
plugin.core_data.cppython_data.dependencies = conan_mock_dependencies
157-
158-
# Execute - should use the profiles resolved during plugin construction
159-
plugin.install()
160-
161-
# Verify that the API was used for installation
162-
conan_setup_mocks['conan_api_constructor'].assert_called_once()
163-
164-
# Verify the rest of the process continued with resolved profiles
165-
conan_mock_api.graph.load_graph_consumer.assert_called_once()
166-
conan_mock_api.install.install_binaries.assert_called_once()
167-
conan_mock_api.install.install_consumer.assert_called_once()
168-
169-
# Verify that the resolved profiles were used in the graph loading
170-
call_args = conan_mock_api.graph.load_graph_consumer.call_args
171-
assert call_args.kwargs['profile_host'] == plugin.data.host_profile
172-
assert call_args.kwargs['profile_build'] == plugin.data.build_profile

0 commit comments

Comments
 (0)