|
16 | 16 |
|
17 | 17 | import pytest |
18 | 18 |
|
19 | | -from cpex.framework.isolated.worker import TaskProcessor, get_environment_info, get_proper_config, main, process_task |
| 19 | +from cpex.framework.isolated.worker import TaskProcessor, get_environment_info, main, process_task |
20 | 20 |
|
21 | 21 |
|
22 | 22 | class TestWorkerFunctions: |
@@ -49,47 +49,6 @@ def test_get_environment_info(self): |
49 | 49 | assert isinstance(info["installed_packages"], list) |
50 | 50 | assert len(info["installed_packages"]) <= 10 # Limited to first 10 |
51 | 51 |
|
52 | | - @patch("cpex.framework.isolated.worker.ConfigLoader.load_config") |
53 | | - def test_get_proper_config_found(self, mock_load_config): |
54 | | - """Test getting proper config when plugin is found.""" |
55 | | - # Create mock plugin config |
56 | | - mock_plugin = MagicMock() |
57 | | - mock_plugin.name = "test_plugin" |
58 | | - mock_plugin.model_dump.return_value = {"name": "test_plugin", "kind": "isolated_venv", "config": {}} |
59 | | - |
60 | | - mock_config = MagicMock() |
61 | | - mock_config.plugins = [mock_plugin] |
62 | | - mock_load_config.return_value = mock_config |
63 | | - |
64 | | - result = get_proper_config("test_plugin") |
65 | | - |
66 | | - assert result is not None |
67 | | - assert result.name == "test_plugin" |
68 | | - |
69 | | - @patch("cpex.framework.isolated.worker.ConfigLoader.load_config") |
70 | | - def test_get_proper_config_not_found(self, mock_load_config): |
71 | | - """Test getting proper config when plugin is not found.""" |
72 | | - mock_plugin = MagicMock() |
73 | | - mock_plugin.name = "other_plugin" |
74 | | - |
75 | | - mock_config = MagicMock() |
76 | | - mock_config.plugins = [mock_plugin] |
77 | | - mock_load_config.return_value = mock_config |
78 | | - |
79 | | - result = get_proper_config("test_plugin") |
80 | | - |
81 | | - assert result is None |
82 | | - |
83 | | - @patch("cpex.framework.isolated.worker.ConfigLoader.load_config") |
84 | | - def test_get_proper_config_no_plugins(self, mock_load_config): |
85 | | - """Test getting proper config when no plugins exist.""" |
86 | | - mock_config = MagicMock() |
87 | | - mock_config.plugins = None |
88 | | - mock_load_config.return_value = mock_config |
89 | | - |
90 | | - result = get_proper_config("test_plugin") |
91 | | - |
92 | | - assert result is None |
93 | 52 |
|
94 | 53 | @pytest.mark.asyncio |
95 | 54 | async def test_process_task_info(self): |
@@ -154,26 +113,6 @@ async def test_process_task_load_and_run_hook_success(self, mock_executor_class, |
154 | 113 | mock_executor.execute_plugin.assert_called_once() |
155 | 114 | self.cleanup_mock_plugin_dirs() |
156 | 115 |
|
157 | | - @pytest.mark.asyncio |
158 | | - @patch("cpex.framework.isolated.worker.get_proper_config") |
159 | | - async def test_process_task_load_and_run_hook_no_config(self, mock_get_config): |
160 | | - """Test processing load_and_run_hook task when config not found.""" |
161 | | - mock_get_config.return_value = None |
162 | | - |
163 | | - config_dict = {"name": "test_plugin", "kind": "isolated_venv"} |
164 | | - task_data = { |
165 | | - "task_type": "load_and_run_hook", |
166 | | - "config": json.dumps(config_dict), |
167 | | - "class_name": "test_plugin.TestPlugin", |
168 | | - "hook_type": "tool_pre_invoke", |
169 | | - "payload": {}, |
170 | | - "context": {"state": {}, "global_context": {}, "metadata": {}}, |
171 | | - } |
172 | | - tp = TaskProcessor() |
173 | | - # Should raise an error or return None |
174 | | - with pytest.raises((AttributeError, TypeError)): |
175 | | - await process_task(task_data, tp) |
176 | | - |
177 | 116 | @pytest.mark.asyncio |
178 | 117 | @patch("cpex.framework.isolated.worker.get_proper_config") |
179 | 118 | @patch("cpex.framework.isolated.worker.importlib.import_module") |
|
0 commit comments