|
25 | 25 |
|
26 | 26 | from unittest.mock import patch
|
27 | 27 |
|
28 |
| -from django.apps import apps |
29 |
| -from django.test import override_settings |
30 |
| - |
31 | 28 | from ansible_ai_connect.ai.api.model_pipelines.factory import ModelPipelineFactory
|
32 | 29 | from ansible_ai_connect.ai.api.model_pipelines.tests import mock_config
|
33 | 30 | from ansible_ai_connect.main.utils import has_wca_providers
|
34 | 31 | from ansible_ai_connect.test_utils import WisdomServiceLogAwareTestCase
|
35 | 32 |
|
36 | 33 |
|
37 |
| -@override_settings(ANSIBLE_AI_MODEL_MESH_CONFIG=mock_config("wca")) |
38 | 34 | class TestHasWCAProvidersWithWCAProvider(WisdomServiceLogAwareTestCase):
|
39 |
| - def setUp(self): |
40 |
| - super().setUp() |
41 |
| - # Patch the pipeline factory to avoid test interference |
42 |
| - self.pipeline_factory_patcher = patch.object( |
43 |
| - apps.get_app_config("ai"), "_pipeline_factory", ModelPipelineFactory() |
44 |
| - ) |
45 |
| - self.pipeline_factory_patcher.start() |
46 |
| - |
47 |
| - def tearDown(self): |
48 |
| - self.pipeline_factory_patcher.stop() |
49 |
| - super().tearDown() |
50 |
| - |
51 | 35 | def test_returns_true_with_wca_provider(self):
|
52 | 36 | """Test that has_wca_providers returns True when WCA provider is configured."""
|
53 |
| - self.assertTrue(has_wca_providers()) |
| 37 | + # Create a factory with WCA config directly, without affecting global state |
| 38 | + with patch( |
| 39 | + "ansible_ai_connect.main.settings.base.ANSIBLE_AI_MODEL_MESH_CONFIG", mock_config("wca") |
| 40 | + ): |
| 41 | + factory = ModelPipelineFactory() |
| 42 | + with patch("ansible_ai_connect.main.utils.apps.get_app_config") as mock_app: |
| 43 | + mock_app.return_value._pipeline_factory = factory |
| 44 | + self.assertTrue(has_wca_providers()) |
54 | 45 |
|
55 | 46 |
|
56 | 47 | # @override_settings(ANSIBLE_AI_MODEL_MESH_CONFIG=mock_config("wca-onprem"))
|
|
0 commit comments