diff options
author | Jessica Tallon <tsyesika@tsyesika.se> | 2015-10-20 12:24:54 +0000 |
---|---|---|
committer | Jessica Tallon <tsyesika@tsyesika.se> | 2015-10-20 12:24:54 +0000 |
commit | 64a456a4e50b03e4fa2b33ceb208e88d2e02fce7 (patch) | |
tree | f60658eb937886dfd1cc349cab605c13a02942e5 /mediagoblin/tests/tools.py | |
parent | fd703bb4d0665958d853b89f6069eefd8a8c8113 (diff) | |
download | mediagoblin-64a456a4e50b03e4fa2b33ceb208e88d2e02fce7.tar.lz mediagoblin-64a456a4e50b03e4fa2b33ceb208e88d2e02fce7.tar.xz mediagoblin-64a456a4e50b03e4fa2b33ceb208e88d2e02fce7.zip |
Comment changes for federation
This adds a new Comment link table that is used to link between some
object and then the comment object, which can be more or less any
object in Mediagoblin. The MediaComment has been renamed to
TextComment as that more aptly describes what it is. There is
migrations for these changes.
There is also the conslidation of the Report tables into a single
Report table, the same with the Notification objects. This is because
both of them split out MediaEntry and Comment versions into their own
polymorphic versions from a base, this is no longer a meaningful
distinction as comments can be anything.
Diffstat (limited to 'mediagoblin/tests/tools.py')
-rw-r--r-- | mediagoblin/tests/tools.py | 50 |
1 files changed, 29 insertions, 21 deletions
diff --git a/mediagoblin/tests/tools.py b/mediagoblin/tests/tools.py index ba143acd..77a9a86c 100644 --- a/mediagoblin/tests/tools.py +++ b/mediagoblin/tests/tools.py @@ -25,9 +25,9 @@ from paste.deploy import loadapp from webtest import TestApp from mediagoblin import mg_globals -from mediagoblin.db.models import User, LocalUser, MediaEntry, Collection, MediaComment, \ - CommentSubscription, CommentNotification, Privilege, CommentReport, Client, \ - RequestToken, AccessToken, Activity, Generator +from mediagoblin.db.models import User, LocalUser, MediaEntry, Collection, TextComment, \ + CommentSubscription, Notification, Privilege, Report, Client, \ + RequestToken, AccessToken, Activity, Generator, Comment from mediagoblin.tools import testing from mediagoblin.init.config import read_mediagoblin_config from mediagoblin.db.base import Session @@ -222,14 +222,16 @@ def fixture_comment_subscription(entry, notify=True, send_email=None): return cs -def fixture_add_comment_notification(entry_id, subject_id, user_id, +def fixture_add_comment_notification(entry, subject, user, seen=False): - cn = CommentNotification(user_id=user_id, - seen=seen, - subject_id=subject_id) + cn = Notification( + user_id=user, + seen=seen, + ) + cn.obj = subject cn.save() - cn = CommentNotification.query.filter_by(id=cn.id).first() + cn = Notification.query.filter_by(id=cn.id).first() Session.expunge(cn) @@ -309,22 +311,27 @@ def fixture_add_comment(author=None, media_entry=None, comment=None): author = fixture_add_user().id if media_entry is None: - media_entry = fixture_media_entry().id + media_entry = fixture_media_entry() if comment is None: comment = \ 'Auto-generated test comment by user #{0} on media #{0}'.format( author, media_entry) - comment = MediaComment(actor=author, - media_entry=media_entry, - content=comment) + text_comment = TextComment( + actor=author, + content=comment + ) + text_comment.save() - comment.save() + comment_link = Comment() + comment_link.target = media_entry + comment_link.comment = text_comment + comment_link.save() - Session.expunge(comment) + Session.expunge(comment_link) - return comment + return text_comment def fixture_add_comment_report(comment=None, reported_user=None, reporter=None, created=None, report_content=None): @@ -344,12 +351,13 @@ def fixture_add_comment_report(comment=None, reported_user=None, report_content = \ 'Auto-generated test report' - comment_report = CommentReport(comment=comment, - reported_user = reported_user, - reporter = reporter, - created = created, - report_content=report_content) - + comment_report = Report() + comment_report.obj = comment + comment_report.reported_user = reported_user + comment_report.reporter = reporter + comment_report.created = created + comment_report.report_content = report_content + comment_report.obj = comment comment_report.save() Session.expunge(comment_report) |