diff options
Diffstat (limited to 'mediagoblin/tests/test_misc.py')
-rw-r--r-- | mediagoblin/tests/test_misc.py | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/mediagoblin/tests/test_misc.py b/mediagoblin/tests/test_misc.py index 2bff0057..558a9bd7 100644 --- a/mediagoblin/tests/test_misc.py +++ b/mediagoblin/tests/test_misc.py @@ -24,7 +24,7 @@ from mediagoblin.db.base import Session from mediagoblin.media_types import sniff_media from mediagoblin.submit.lib import new_upload_entry from mediagoblin.submit.task import collect_garbage -from mediagoblin.db.models import User, MediaEntry, MediaComment +from mediagoblin.db.models import User, MediaEntry, TextComment, Comment from mediagoblin.tests.tools import fixture_add_user, fixture_media_entry @@ -46,25 +46,31 @@ def test_user_deletes_other_comments(test_app): Session.flush() # Create all 4 possible comments: - for u_id in (user_a.id, user_b.id): - for m_id in (media_a.id, media_b.id): - cmt = MediaComment() - cmt.media_entry = m_id - cmt.actor = u_id + for u in (user_a, user_b): + for m in (media_a, media_b): + cmt = TextComment() + cmt.actor = u.id cmt.content = u"Some Comment" Session.add(cmt) + # think i need this to get the command ID + Session.flush() + + link = Comment() + link.target = m + link.comment = cmt + Session.add(link) Session.flush() usr_cnt1 = User.query.count() med_cnt1 = MediaEntry.query.count() - cmt_cnt1 = MediaComment.query.count() + cmt_cnt1 = TextComment.query.count() User.query.get(user_a.id).delete(commit=False) usr_cnt2 = User.query.count() med_cnt2 = MediaEntry.query.count() - cmt_cnt2 = MediaComment.query.count() + cmt_cnt2 = TextComment.query.count() # One user deleted assert usr_cnt2 == usr_cnt1 - 1 @@ -77,7 +83,7 @@ def test_user_deletes_other_comments(test_app): usr_cnt2 = User.query.count() med_cnt2 = MediaEntry.query.count() - cmt_cnt2 = MediaComment.query.count() + cmt_cnt2 = TextComment.query.count() # All users gone assert usr_cnt2 == usr_cnt1 - 2 |