aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElrond <elrond+mediagoblin.org@samba-tng.org>2012-02-26 15:15:10 +0100
committerElrond <elrond+mediagoblin.org@samba-tng.org>2012-03-26 20:31:35 +0200
commit37ef4c66b1bc5841b68bf25f06feb7d863ff89f5 (patch)
treeccc6774c176b1dafa0fdde0867803a34a72cdad1
parent38877794e73ab9c23e11bf5a22263c1d1d5b083c (diff)
downloadmediagoblin-37ef4c66b1bc5841b68bf25f06feb7d863ff89f5.tar.lz
mediagoblin-37ef4c66b1bc5841b68bf25f06feb7d863ff89f5.tar.xz
mediagoblin-37ef4c66b1bc5841b68bf25f06feb7d863ff89f5.zip
Reload and detach the test user.
The code often needs to know some fields of the test user even after doing some sql and stuff. The solultion is to reload it and properly detach it from its Session. That way all its fields are available and the whole thing is not connected to a session. It feels like a normal object.
-rw-r--r--mediagoblin/tests/tools.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/mediagoblin/tests/tools.py b/mediagoblin/tests/tools.py
index a99173e8..5b4e3746 100644
--- a/mediagoblin/tests/tools.py
+++ b/mediagoblin/tests/tools.py
@@ -212,4 +212,11 @@ def fixture_add_user(username = u'chris', password = 'toast',
test_user.save()
+ # Reload
+ test_user = mg_globals.database.User.find_one({'username': username})
+
+ # ... and detach from session:
+ from mediagoblin.db.sql.base import Session
+ Session.expunge(test_user)
+
return test_user