"""Tests for ListCommentsUseCase. This module tests the comment listing use case covering retrieval of comments by post ID. """ from unittest.mock import AsyncMock, Mock from uuid import uuid4 import pytest from app.application.use_cases.list_comments import ListCommentsUseCase from app.domain.entities.comment import Comment class TestListCommentsUseCase: """Tests for ListCommentsUseCase. Covers TC-UNIT-835. """ @pytest.mark.asyncio async def test_list_comments_by_post( self, mock_transaction_manager: Mock, ) -> None: """Test listing comments for a post. TC-UNIT-835: Positive — returns comments for given post_id. """ post_id = uuid4() author_id = "user-123" comments = [ Comment.create( post_id=post_id, author_id=author_id, content_str="First comment.", ), Comment.create( post_id=post_id, author_id="user-456", content_str="Second comment.", ), ] mock_comment_repository = AsyncMock() mock_comment_repository.get_by_post = AsyncMock(return_value=comments) use_case = ListCommentsUseCase( comment_repo=mock_comment_repository, ) result = await use_case.execute(post_id=post_id) assert len(result) == 2 assert result[0].post_id == post_id assert result[0].author_id == author_id assert result[1].author_id == "user-456" mock_comment_repository.get_by_post.assert_called_once_with(post_id)