Fix unit tests for sql: cache media_id.
authorElrond <elrond+mediagoblin.org@samba-tng.org>
Sun, 1 Apr 2012 20:02:06 +0000 (22:02 +0200)
committerElrond <elrond+mediagoblin.org@samba-tng.org>
Sun, 1 Apr 2012 20:02:06 +0000 (22:02 +0200)
Attributes of SQLAlchemy objects get "lost". So "cache"
them locally in the code.
This is really the simple explanation for some scarry
sqlalchemy details.

mediagoblin/tests/test_submission.py

index 788dfacf59878023343410dd5d258009e89a38d0..9b503f4fd70bc1cf9d14bf5eb4404a55bb56342f 100644 (file)
@@ -183,8 +183,9 @@ class TestSubmission:
         assert_true(media)
 
         # Add a comment, so we can test for its deletion later.
+        media_id = media.id
         get_comments = lambda: list(
-            request.db.MediaComment.find({'media_entry': media._id}))
+            request.db.MediaComment.find({'media_entry': media_id}))
         assert_false(get_comments())
         response = self.test_app.post(
             request.urlgen('mediagoblin.user_pages.media_post_comment',
@@ -200,7 +201,7 @@ class TestSubmission:
             request.urlgen('mediagoblin.user_pages.media_confirm_delete',
                            # No work: user=media.uploader().username,
                            user=self.test_user.username,
-                           media=media._id),
+                           media=media_id),
             # no value means no confirm
             {})