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
Example #2
0
def comment_dtos():
    comment_dtos = [
        CommentDto(comment_id=1,
                   commented_by_id=1,
                   post_id=1,
                   commented_at=datetime.datetime(2019, 5, 19, 0, 0),
                   content='Thanks.......',
                   parent_comment_id=None),
        CommentDto(comment_id=2,
                   commented_by_id=2,
                   post_id=1,
                   commented_at=datetime.datetime(2019, 5, 19, 0, 0),
                   content='Thanks.......',
                   parent_comment_id=1)
    ]
    return comment_dtos
def get_post_comment_dtos():
    comment_obj_dto = [
        CommentDto(comment_id=1,
                   commented_by_id=1,
                   post_id=1,
                   commented_at=datetime.datetime(2020, 10, 10, 0, 0),
                   content='New Comment1',
                   parent_comment_id=None),
        CommentDto(comment_id=2,
                   commented_by_id=2,
                   post_id=1,
                   commented_at=datetime.datetime(2020, 10, 10, 0, 0),
                   content='New Comment2',
                   parent_comment_id=1)
    ]
    return comment_obj_dto
    def test_get_user_posts_extra_dto_details_for_presenter_comment_with_no_replies(
            self, post_dto, reaction_dtos, user_dtos):

        # Arrange
        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=2,
                             commented_at = \
                                datetime.datetime(2020, 10, 10, 0, 0) ,
                             content='HII',
                             parent_comment_id=None)
        testing_comment_dtos_list = [comment1, comment2]

        expected_comment_count_dtos = [
            CommentWithRepliesCountDto(comment_id=1, replies_count=0),
            CommentWithRepliesCountDto(comment_id=2, replies_count=0)
        ]
        post_complete_dto = [
            PostCompleteDetailsDto(user_dtos=user_dtos,
                                   post_dto=post_dto,
                                   comment_dtos= \
                                       testing_comment_dtos_list,
                                   reaction_dtos=reaction_dtos)
        ]

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

        # Act
        (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_comment_replies_count_dto_list == \
            expected_comment_count_dtos
Example #5
0
def comment_dto():
    comment_obj_dto = CommentDto(comment_id=1,
                                 commented_by_id=1,
                                 post_id=1,
                                 commented_at=datetime.datetime(
                                     2019, 5, 19, 0, 0),
                                 content='Thanks.......',
                                 parent_comment_id=None)
    return comment_obj_dto
Example #6
0
 def _convert_comment_obj_to_dto(comment):
     comment_dto = CommentDto(comment_id=comment.id,
                              commented_by_id=comment.commented_by_id,
                              post_id=comment.post_id,
                              commented_at=comment.commented_at.replace(
                                  tzinfo=None),
                              content=comment.content,
                              parent_comment_id=comment.parent_comment_id)
     return comment_dto
Example #7
0
 def _convert_reply_obj_to_dto(reply):
     reply_dto = CommentDto(comment_id=reply.id,
                            commented_by_id=reply.commented_by_id,
                            post_id=reply.post_id,
                            commented_at=reply.commented_at.replace(
                                tzinfo=None),
                            content=reply.content,
                            parent_comment_id=reply.parent_comment_id)
     return reply_dto