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.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user