@@ -71,6 +71,12 @@ async def test_initialize_success(self):
7171 mock_nim_client = AsyncMock ()
7272 mock_db_service = AsyncMock ()
7373
74+ # Import the module first to ensure it's available for patching
75+ try :
76+ import src .api .services .document
77+ except ImportError :
78+ pass # Module might not be importable in test environment
79+
7480 # Patch the module import - need to patch where it's imported from
7581 with patch ("src.api.agents.document.action_tools.get_nim_client" , return_value = mock_nim_client ), \
7682 patch ("src.api.services.document.get_document_db_service" , return_value = mock_db_service ), \
@@ -89,9 +95,15 @@ async def test_initialize_without_database_fallback(self):
8995
9096 mock_nim_client = AsyncMock ()
9197
98+ # Import the module first to ensure it's available for patching
99+ try :
100+ import src .api .services .document
101+ except ImportError :
102+ pass # Module might not be importable in test environment
103+
92104 # Patch the module import - need to patch where it's imported from
93105 with patch ("src.api.agents.document.action_tools.get_nim_client" , return_value = mock_nim_client ), \
94- patch ("src.api.services.document.get_document_db_service" , side_effect = ImportError ("DB unavailable" )), \
106+ patch ("src.api.services.document.get_document_db_service" , side_effect = Exception ("DB unavailable" )), \
95107 patch .object (tools , "_load_status_data" ):
96108
97109 await tools .initialize ()
0 commit comments