Coverage for src/app/services/update_message_rating_service.py: 100%

11 statements  

« prev     ^ index     » next       coverage.py v7.7.0, created at 2025-04-03 00:42 +0200

1from ports.update_message_rating_port import UpdateMessageRatingPort 

2from models.message_model import MessageModel 

3from usecases.update_message_rating_useCase import UpdateMessageRatingUseCase 

4 

5class UpdateMessageRatingService(UpdateMessageRatingUseCase): 

6 """ 

7 Service class to update 

8 the rating of a message. 

9 """ 

10 def __init__(self, update_message_rating_port: UpdateMessageRatingPort): 

11 self.update_message_rating_port = update_message_rating_port 

12 

13 def update_message_rating(self, message: MessageModel) -> bool: 

14 """ 

15 Update the rating of a message. 

16 Args: 

17 message (MessageModel): The message containing the ID and the new rating value. 

18 Returns: 

19 bool: True if the rating was successfully updated, False otherwise. 

20 """ 

21 try: 

22 return self.update_message_rating_port.update_message_rating(message) 

23 except Exception as e: 

24 raise e