Esempio n. 1
0
def test_comments_removed_when_graveyarded(test_app):
    """ Checks comments which are tombstones are removed from collection """
    user = fixture_add_user()
    media = fixture_media_entry(uploader=user.id,
                                expunge=False,
                                fake_upload=False)

    # Add the TextComment
    comment = TextComment()
    comment.actor = user.id
    comment.content = u"This is a comment that will be deleted."
    comment.save()

    # Add a link for the comment
    link = Comment()
    link.target = media
    link.comment = comment
    link.save()

    # First double check it's there and all is well...
    assert Comment.query.filter_by(
        target_id=link.target_id).first() is not None

    # Now delete the comment.
    comment.delete()

    # Verify this also deleted the Comment link, ergo there is no comment left.
    assert Comment.query.filter_by(target_id=link.target_id).first() is None
Esempio n. 2
0
def test_comments_removed_when_graveyarded(test_app):
    """ Checks comments which are tombstones are removed from collection """
    user = fixture_add_user()
    media = fixture_media_entry(
        uploader=user.id,
        expunge=False,
        fake_upload=False
    )
    
    # Add the TextComment
    comment = TextComment()
    comment.actor = user.id
    comment.content = u"This is a comment that will be deleted."
    comment.save()

    # Add a link for the comment
    link = Comment()
    link.target = media
    link.comment = comment
    link.save()

    # First double check it's there and all is well...
    assert Comment.query.filter_by(target_id=link.target_id).first() is not None

    # Now delete the comment.
    comment.delete()

    # Verify this also deleted the Comment link, ergo there is no comment left.
    assert Comment.query.filter_by(target_id=link.target_id).first() is None
Esempio n. 3
0
def fixture_add_comment(author=None, media_entry=None, comment=None):
    if author is None:
        author = fixture_add_user().id

    if media_entry is None:
        media_entry = fixture_media_entry()

    if comment is None:
        comment = \
            'Auto-generated test comment by user #{0} on media #{0}'.format(
                author, media_entry)

    text_comment = TextComment(
        actor=author,
        content=comment
    )
    text_comment.save()

    comment_link = Comment()
    comment_link.target = media_entry
    comment_link.comment = text_comment
    comment_link.save()

    Session.expunge(comment_link)

    return text_comment
Esempio n. 4
0
def fixture_add_comment(author=None, media_entry=None, comment=None):
    if author is None:
        author = fixture_add_user().id

    if media_entry is None:
        media_entry = fixture_media_entry()

    if comment is None:
        comment = \
            'Auto-generated test comment by user #{0} on media #{0}'.format(
                author, media_entry)

    text_comment = TextComment(actor=author, content=comment)
    text_comment.save()

    comment_link = Comment()
    comment_link.target = media_entry
    comment_link.comment = text_comment
    comment_link.save()

    Session.expunge(comment_link)

    return text_comment