diff options
author | Jessica Tallon <jessica@megworld.co.uk> | 2014-10-21 11:44:11 +0100 |
---|---|---|
committer | Jessica Tallon <jessica@megworld.co.uk> | 2014-10-21 11:44:11 +0100 |
commit | 5ddc85e071fd7adec6b922a03c2e8caa4bad3c5c (patch) | |
tree | 832007aa1223b14ea84e2a1235313381941a21a9 /mediagoblin/tests/tools.py | |
parent | a806e4dcc4921fa309f83bce82b367a699dc9636 (diff) | |
download | mediagoblin-5ddc85e071fd7adec6b922a03c2e8caa4bad3c5c.tar.lz mediagoblin-5ddc85e071fd7adec6b922a03c2e8caa4bad3c5c.tar.xz mediagoblin-5ddc85e071fd7adec6b922a03c2e8caa4bad3c5c.zip |
Fix #984 - Improvements to Activity and ActivityIntermediator
- Add unit tests to cover get and set methods on Activity
- Rewrite the set to remove set and use Session.flush instead
- Use sqlalchemy's validator instead of .save hack
Diffstat (limited to 'mediagoblin/tests/tools.py')
-rw-r--r-- | mediagoblin/tests/tools.py | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/mediagoblin/tests/tools.py b/mediagoblin/tests/tools.py index 7d29321b..dec95e83 100644 --- a/mediagoblin/tests/tools.py +++ b/mediagoblin/tests/tools.py @@ -27,7 +27,7 @@ from webtest import TestApp from mediagoblin import mg_globals from mediagoblin.db.models import User, MediaEntry, Collection, MediaComment, \ CommentSubscription, CommentNotification, Privilege, CommentReport, Client, \ - RequestToken, AccessToken + RequestToken, AccessToken, Activity, Generator from mediagoblin.tools import testing from mediagoblin.init.config import read_mediagoblin_config from mediagoblin.db.base import Session @@ -346,3 +346,28 @@ def fixture_add_comment_report(comment=None, reported_user=None, Session.expunge(comment_report) return comment_report + +def fixture_add_activity(obj, verb="post", target=None, generator=None, actor=None): + if generator is None: + generator = Generator( + name="GNU MediaGoblin", + object_type="service" + ) + generator.save() + + if actor is None: + actor = fixture_add_user() + + activity = Activity( + verb=verb, + actor=actor.id, + generator=generator.id, + ) + + activity.set_object(obj) + + if target is not None: + activity.set_target(target) + + activity.save() + return activity
\ No newline at end of file |