def test_get_post_extra_details_dtos_for_presenter_with_post_no_comments(
            self, post_dto):

        # Arrrange
        expected_post_comment_count_dtos_list = [
            PostWithCommentsCountDto(post_id=1, comments_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=[],
                                                   post_dto=post_dto,
                                                   comment_dtos=[],
                                                   reaction_dtos=[])

        # Act
        (actual_post_comment_count_dtos_list,
        post_reactions_details_dto_list,
        actual_comment_replies_count_dto_list,
        comment_reactions_details_dto_list) = interactor. \
            get_post_extra_details_dtos_for_presenter(post_complete_dto)

        # Assert
        assert actual_post_comment_count_dtos_list == \
            expected_post_comment_count_dtos_list
    def _get_post_comments_count_dtos(self, post_id, comments_dtos):
        count = len(comments_dtos)

        post_with_comments_count_dtos_list = [
            PostWithCommentsCountDto(post_id=post_id, comments_count=count)
        ]

        return post_with_comments_count_dtos_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 test_get_user_posts_extra_dto_details_for_presenter_with_post_with_comments(
            self, post_dto):

        # Arrrange
        expected_post_comment_count_dtos_list = [
            PostWithCommentsCountDto(post_id=1, comments_count=2)
        ]
        comment1 = CommentDto(comment_id=1,
                             commented_by_id=1,
                             post_id=1,
                             commented_at = \
                                datetime.datetime(2020, 10, 10, 0, 0),
                             content='HII',
                             parent_comment_id=None)
        comment2 = CommentDto(comment_id=2,
                             commented_by_id=2,
                             post_id=1,
                             commented_at = \
                                datetime.datetime(2020, 10, 10, 0, 0),
                             content='HII',
                             parent_comment_id=1)
        comment3 = CommentDto(comment_id=3,
                             commented_by_id=2,
                             post_id=1,
                             commented_at = \
                                datetime.datetime(2020, 10, 10, 0, 0),
                             content='HII',
                             parent_comment_id=None)
        comments_dtos_list = [comment1, comment2, comment3]
        post_storage = create_autospec(PostStorageInterface)
        presenter = create_autospec(PresenterInterface)
        interactor = GetUserPostsInteractor(post_storage=post_storage,
                                            presenter=presenter)

        post_complete_dto = [
            PostCompleteDetailsDto(user_dtos=[],
                                   post_dto=post_dto,
                                   comment_dtos= \
                                       comments_dtos_list,
                                   reaction_dtos=[])
        ]

        # Act
        (actual_post_comment_count_dtos_list,
        post_reactions_details_dto_list,
        actual_comment_replies_count_dto_list,
        comment_reactions_details_dto_list) = interactor. \
            get_user_posts_extra_dto_details_for_presenter(post_complete_dto)

        # Assert
        assert actual_post_comment_count_dtos_list == \
            expected_post_comment_count_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