77from app .endpoints .conversations import (
88 get_conversation_endpoint_handler ,
99 delete_conversation_endpoint_handler ,
10- conversation_id_to_agent_id ,
1110 simplify_session_data ,
1211)
1312from models .responses import ConversationResponse , ConversationDeleteResponse
@@ -48,16 +47,6 @@ def setup_configuration_fixture():
4847 return cfg
4948
5049
51- @pytest .fixture (autouse = True )
52- def setup_conversation_mapping ():
53- """Set up and clean up the conversation ID to agent ID mapping."""
54- # Clear the mapping before each test
55- conversation_id_to_agent_id .clear ()
56- yield
57- # Clean up after each test
58- conversation_id_to_agent_id .clear ()
59-
60-
6150@pytest .fixture (name = "mock_session_data" )
6251def mock_session_data_fixture ():
6352 """Create mock session data for testing."""
@@ -243,9 +232,6 @@ def test_llama_stack_connection_error(self, mocker, setup_configuration):
243232 mocker .patch ("app.endpoints.conversations.configuration" , setup_configuration )
244233 mocker .patch ("app.endpoints.conversations.check_suid" , return_value = True )
245234
246- # Set up conversation mapping
247- conversation_id_to_agent_id [VALID_CONVERSATION_ID ] = VALID_AGENT_ID
248-
249235 # Mock LlamaStackClientHolder to raise APIConnectionError
250236 mock_client = mocker .Mock ()
251237 mock_client .agents .session .retrieve .side_effect = APIConnectionError (
@@ -268,9 +254,6 @@ def test_llama_stack_not_found_error(self, mocker, setup_configuration):
268254 mocker .patch ("app.endpoints.conversations.configuration" , setup_configuration )
269255 mocker .patch ("app.endpoints.conversations.check_suid" , return_value = True )
270256
271- # Set up conversation mapping
272- conversation_id_to_agent_id [VALID_CONVERSATION_ID ] = VALID_AGENT_ID
273-
274257 # Mock LlamaStackClientHolder to raise NotFoundError
275258 mock_client = mocker .Mock ()
276259 mock_client .agents .session .retrieve .side_effect = NotFoundError (
@@ -294,9 +277,6 @@ def test_session_retrieve_exception(self, mocker, setup_configuration):
294277 mocker .patch ("app.endpoints.conversations.configuration" , setup_configuration )
295278 mocker .patch ("app.endpoints.conversations.check_suid" , return_value = True )
296279
297- # Set up conversation mapping
298- conversation_id_to_agent_id [VALID_CONVERSATION_ID ] = VALID_AGENT_ID
299-
300280 # Mock LlamaStackClientHolder to raise a general exception
301281 mock_client = mocker .Mock ()
302282 mock_client .agents .session .retrieve .side_effect = Exception (
@@ -323,9 +303,6 @@ def test_successful_conversation_retrieval(
323303 mocker .patch ("app.endpoints.conversations.configuration" , setup_configuration )
324304 mocker .patch ("app.endpoints.conversations.check_suid" , return_value = True )
325305
326- # Set up conversation mapping
327- conversation_id_to_agent_id [VALID_CONVERSATION_ID ] = VALID_AGENT_ID
328-
329306 # Mock session data with model_dump method
330307 mock_session_obj = mocker .Mock ()
331308 mock_session_obj .model_dump .return_value = mock_session_data
@@ -394,9 +371,6 @@ def test_llama_stack_connection_error(self, mocker, setup_configuration):
394371 mocker .patch ("app.endpoints.conversations.configuration" , setup_configuration )
395372 mocker .patch ("app.endpoints.conversations.check_suid" , return_value = True )
396373
397- # Set up conversation mapping
398- conversation_id_to_agent_id [VALID_CONVERSATION_ID ] = VALID_AGENT_ID
399-
400374 # Mock LlamaStackClientHolder to raise APIConnectionError
401375 mock_client = mocker .Mock ()
402376 mock_client .agents .session .delete .side_effect = APIConnectionError (request = None )
@@ -416,9 +390,6 @@ def test_llama_stack_not_found_error(self, mocker, setup_configuration):
416390 mocker .patch ("app.endpoints.conversations.configuration" , setup_configuration )
417391 mocker .patch ("app.endpoints.conversations.check_suid" , return_value = True )
418392
419- # Set up conversation mapping
420- conversation_id_to_agent_id [VALID_CONVERSATION_ID ] = VALID_AGENT_ID
421-
422393 # Mock LlamaStackClientHolder to raise NotFoundError
423394 mock_client = mocker .Mock ()
424395 mock_client .agents .session .delete .side_effect = NotFoundError (
@@ -442,9 +413,6 @@ def test_session_deletion_exception(self, mocker, setup_configuration):
442413 mocker .patch ("app.endpoints.conversations.configuration" , setup_configuration )
443414 mocker .patch ("app.endpoints.conversations.check_suid" , return_value = True )
444415
445- # Set up conversation mapping
446- conversation_id_to_agent_id [VALID_CONVERSATION_ID ] = VALID_AGENT_ID
447-
448416 # Mock LlamaStackClientHolder to raise a general exception
449417 mock_client = mocker .Mock ()
450418 mock_client .agents .session .delete .side_effect = Exception (
@@ -470,9 +438,6 @@ def test_successful_conversation_deletion(self, mocker, setup_configuration):
470438 mocker .patch ("app.endpoints.conversations.configuration" , setup_configuration )
471439 mocker .patch ("app.endpoints.conversations.check_suid" , return_value = True )
472440
473- # Set up conversation mapping
474- conversation_id_to_agent_id [VALID_CONVERSATION_ID ] = VALID_AGENT_ID
475-
476441 # Mock LlamaStackClientHolder
477442 mock_client = mocker .Mock ()
478443 mock_client .agents .session .delete .return_value = None # Successful deletion
0 commit comments