|
6 | 6 |
|
7 | 7 | import pytest |
8 | 8 | from packaging.requirements import Requirement |
9 | | -from pytest_mock import MockerFixture |
10 | 9 |
|
11 | 10 | from cppython.plugins.conan.plugin import ConanProvider |
12 | | -from cppython.plugins.conan.schema import ConanDependency |
13 | 11 | from cppython.test.pytest.mixins import ProviderPluginTestMixin |
14 | | -from cppython.utility.exception import ProviderInstallationError |
15 | 12 |
|
16 | 13 | # Constants for test assertions |
17 | 14 | EXPECTED_PROFILE_CALLS = 2 |
@@ -81,92 +78,3 @@ def test_with_dependencies( |
81 | 78 |
|
82 | 79 | # Verify build path was created |
83 | 80 | 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