def test_get_post_extra_details_dtos_for_presenter_with_comment_with_reactions(
            self, post_dto, user_dtos, comment_dtos,
            comment_reactions_dtos_with_duplicates):

        # Arrrange
        expected_comment_reactions_details_dto_list = [
            CommentWithReactionDetailsDto(comment_id=1,
                                          reaction_type=["LIT", "LOVE", "WOW"],
                                          count=4),
            CommentWithReactionDetailsDto(comment_id=2,
                                          reaction_type=[],
                                          count=0),
        ]
        post_storage = create_autospec(PostStorageInterface)
        presenter = create_autospec(PresenterInterface)
        interactor = GetPostInteractor(post_storage=post_storage,
                                       presenter=presenter)

        post_complete_dto = PostCompleteDetailsDto(
            user_dtos=user_dtos,
            post_dto=post_dto,
            comment_dtos=comment_dtos,
            reaction_dtos= \
                comment_reactions_dtos_with_duplicates)

        # Act
        (post_comment_count_dtos_list,
        post_reactions_details_dto_list,
        comment_replies_count_dto_list,
        actual_comment_reactions_details_dto_list) = interactor. \
            get_post_extra_details_dtos_for_presenter(post_complete_dto)

        # Assert
        assert actual_comment_reactions_details_dto_list == \
            expected_comment_reactions_details_dto_list
    def test_get_user_posts_extra_dto_details_for_presenter(
            self, user_dtos, post_dto, comment_dtos, reaction_dtos):

        # Arrange
        post_id = 1

        post_storage = create_autospec(PostStorageInterface)
        presenter = create_autospec(PresenterInterface)
        interactor = GetUserPostsInteractor(post_storage=post_storage,
                                            presenter=presenter)

        exp_post_comment_count_dtos_list = [
            PostWithCommentsCountDto(post_id=1, comments_count=1)
        ]

        exp_post_reactions_details_dto_list = [
            PostWithReactionDetailsDto(post_id=1,
                                       reaction_type=["WOW"],
                                       count=1)
        ]

        exp_comment_replies_count_dto_list = [
            CommentWithRepliesCountDto(comment_id=1, replies_count=1)
        ]

        exp_comment_reactions_details_dto_list = [
            CommentWithReactionDetailsDto(comment_id=1,
                                          reaction_type=[],
                                          count=0),
            CommentWithReactionDetailsDto(comment_id=2,
                                          reaction_type=["LOVE"],
                                          count=1)
        ]

        get_user_posts_dto = [
            PostCompleteDetailsDto(user_dtos=user_dtos,
                                   post_dto=post_dto,
                                   comment_dtos=comment_dtos,
                                   reaction_dtos=reaction_dtos)
        ]

        # Act
        (post_comment_count_dtos_list, post_reactions_details_dto_list,
        comment_replies_count_dto_list, comment_reactions_details_dto_list) = \
            interactor.get_user_posts_extra_dto_details_for_presenter(
                post_dtos_list=get_user_posts_dto)

        # Assert
        assert post_comment_count_dtos_list == \
             exp_post_comment_count_dtos_list
        assert post_reactions_details_dto_list == \
             exp_post_reactions_details_dto_list
        assert comment_replies_count_dto_list == \
            exp_comment_replies_count_dto_list
        assert comment_reactions_details_dto_list == \
            exp_comment_reactions_details_dto_list
    def _get_comment_with_reaction_details_dtos(self, comments, reactions):
        reactions_dtos_list = []

        for comment in comments:
            count, reactions_list = self._get_comment_id_reactions_details(
                comment.comment_id, reactions)
            dto = CommentWithReactionDetailsDto(comment_id=comment.comment_id,
                                                reaction_type=reactions_list,
                                                count=count)
            reactions_dtos_list.append(dto)
        return reactions_dtos_list
    def test_get_user_posts_extra_dto_details_for_presenter_with_multiple_data(
            self, user_dtos, create_user_posts_dtos,
            post_reactions_dtos_with_duplicates,
            comment_reactions_dtos_with_duplicates, comment_dtos,
            reaction_dtos):

        # Arrange
        post_id = 1
        post_storage = create_autospec(PostStorageInterface)
        presenter = create_autospec(PresenterInterface)
        interactor = GetUserPostsInteractor(post_storage=post_storage,
                                            presenter=presenter)
        post_and_comments_reactions_dtos = \
            (post_reactions_dtos_with_duplicates
            + comment_reactions_dtos_with_duplicates)

        exp_post_comment_count_dtos_list = [
            PostWithCommentsCountDto(post_id=1, comments_count=1),
            PostWithCommentsCountDto(post_id=2, comments_count=0)
        ]

        exp_post_reactions_details_dto_list = [
            PostWithReactionDetailsDto(post_id=1,
                                       reaction_type=["LIT", "LOVE", "WOW"],
                                       count=4),
            PostWithReactionDetailsDto(post_id=2, reaction_type=[], count=0)
        ]

        exp_comment_replies_count_dto_list = [
            CommentWithRepliesCountDto(comment_id=1, replies_count=1)
        ]

        exp_comment_reactions_details_dto_list = [
            CommentWithReactionDetailsDto(comment_id=1,
                                          reaction_type=["LIT", "LOVE", "WOW"],
                                          count=4),
            CommentWithReactionDetailsDto(comment_id=2,
                                          reaction_type=[],
                                          count=0)
        ]

        get_user_posts_dto = [
            PostCompleteDetailsDto(
                user_dtos=user_dtos,
                post_dto=create_user_posts_dtos[0],
                comment_dtos=comment_dtos,
                reaction_dtos=post_and_comments_reactions_dtos),
            PostCompleteDetailsDto(user_dtos=[],
                                   post_dto=create_user_posts_dtos[1],
                                   comment_dtos=[],
                                   reaction_dtos=reaction_dtos)
        ]

        # Act
        (post_comment_count_dtos_list, post_reactions_details_dto_list,
        comment_replies_count_dto_list, comment_reactions_details_dto_list) = \
            interactor.get_user_posts_extra_dto_details_for_presenter(
                post_dtos_list=get_user_posts_dto)

        # Assert
        assert post_comment_count_dtos_list == \
             exp_post_comment_count_dtos_list
        assert post_reactions_details_dto_list == \
             exp_post_reactions_details_dto_list
        assert comment_replies_count_dto_list == \
            exp_comment_replies_count_dto_list
        assert comment_reactions_details_dto_list == \
            exp_comment_reactions_details_dto_list