Coverage for src/app/controllers/get_conversation_controller.py: 54%
13 statements
« prev ^ index » next coverage.py v7.7.0, created at 2025-04-03 00:51 +0200
« prev ^ index » next coverage.py v7.7.0, created at 2025-04-03 00:51 +0200
1from usecases.get_conversation_useCase import GetConversationUseCase
2from dto.conversation_dto import ConversationDTO
3from models.conversation_model import ConversationModel
5class GetConversationController:
7 def __init__(self, get_conversation_use_case: GetConversationUseCase):
8 self.get_conversation_use_case = get_conversation_use_case
10 def get_conversation(self, conversation_dto: ConversationDTO) -> ConversationDTO:
11 """
12 get the conversation title from db using id to get it.
13 Args:
14 conversation (ConversationDTO): The conversation to be retrieved.
15 Returns:
16 ConversationDTO: The conversation retrieved from db.
17 """
18 try:
19 conversation_model = ConversationModel(
20 id=conversation_dto.get_id(),
21 title=conversation_dto.get_title(),
22 user_id=conversation_dto.get_user_id()
23 )
25 conversation_result = self.get_conversation_use_case.get_conversation(conversation_model)
27 return ConversationDTO(
28 id=conversation_result.get_id(),
29 title=conversation_result.get_title(),
30 user_id=conversation_result.get_user_id()
31 )
33 except Exception as e:
34 raise e