Example #1
0
def test_comment_card_templates_are_per_post(user, post1, post2):
    assert (templates.CommentCardTemplate(
        user.id, post1.id,
        1).card_id == templates.CommentCardTemplate(user.id, post1.id,
                                                    1).card_id)
    assert (templates.CommentCardTemplate(user.id, post1.id, 1).card_id !=
            templates.CommentCardTemplate(user.id, post2.id, 1).card_id)
Example #2
0
def test_comment_card_template_titles(user, post):
    template = templates.CommentCardTemplate(user.id, post.id, 1)
    assert template.title == 'You have 1 new comment'

    template = templates.CommentCardTemplate(user.id, post.id, 2)
    assert template.title == 'You have 2 new comments'

    template = templates.CommentCardTemplate(user.id, post.id, 42)
    assert template.title == 'You have 42 new comments'
Example #3
0
def test_comment_cards_are_per_post(user, card_manager, post1, post2):
    template1 = templates.CommentCardTemplate(user.id, post1.id, unviewed_comments_count=4)
    template2 = templates.CommentCardTemplate(user.id, post2.id, unviewed_comments_count=3)

    # verify starting state
    assert card_manager.get_card(template1.card_id) is None
    assert card_manager.get_card(template2.card_id) is None

    # add the card, verify state
    card_manager.add_or_update_card(template1)
    assert card_manager.get_card(template1.card_id)
    assert card_manager.get_card(template2.card_id) is None

    # add the other card, verify state and no conflict
    card_manager.add_or_update_card(template2)
    assert card_manager.get_card(template1.card_id)
    assert card_manager.get_card(template2.card_id)
Example #4
0
def test_comment_card_template(user, post):
    card_id = templates.CommentCardTemplate.get_card_id(user.id, post.id)
    assert card_id.split(':') == [user.id, 'COMMENT_ACTIVITY', post.id]

    template = templates.CommentCardTemplate(user.id, post.id, 1)
    assert template.card_id == card_id
    assert template.user_id == user.id
    assert template.action == f'https://real.app/user/{user.id}/post/{post.id}/comments'
    assert not template.only_usernames
    assert template.post_id == post.id
    assert not template.comment_id
def comment_card_template(card_manager, post):
    template = templates.CommentCardTemplate(post.user_id, post.id, unviewed_comments_count=42)
    card_manager.add_or_update_card(template)
    yield template
Example #6
0
def comment_card_template(user, post):
    yield templates.CommentCardTemplate(user.id,
                                        post.id,
                                        unviewed_comments_count=4)