aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/tests/test_edit.py
diff options
context:
space:
mode:
authorJessica Tallon <tsyesika@tsyesika.se>2015-08-24 18:28:41 +0200
committerJessica Tallon <tsyesika@tsyesika.se>2015-08-24 21:07:06 +0200
commitb4997540dcc7b75441e9b10ee6dcac32cc2708be (patch)
treee543baf0acc77214c44bad9f826d9187459539a9 /mediagoblin/tests/test_edit.py
parente9bb5879f772e4d546aadb4bb6f935c7c55b8000 (diff)
downloadmediagoblin-b4997540dcc7b75441e9b10ee6dcac32cc2708be.tar.lz
mediagoblin-b4997540dcc7b75441e9b10ee6dcac32cc2708be.tar.xz
mediagoblin-b4997540dcc7b75441e9b10ee6dcac32cc2708be.zip
Fix some unit tests and bugs
This fixes a lot of the issues with the LocalUser changes that were merged recently. There was a problem where the attributes of LocalUser were not being eagerly loaded and because the Session was detached an exception was being raised when they were accessed. This also fixes some typo's which were introduced. Finally this adds a temporary fix for a potential SQLAlchemy bug, this is a bug where doing: User.query.filter(LocalUser.username == "some_username").first() does NOT yeild a user with the username "some_username" but all users on the site. The temp fix is to just query the LocalUser, this should be resolved when bug is confirmed and fixed upstream.
Diffstat (limited to 'mediagoblin/tests/test_edit.py')
-rw-r--r--mediagoblin/tests/test_edit.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/mediagoblin/tests/test_edit.py b/mediagoblin/tests/test_edit.py
index 3bf85edf..632c8e3c 100644
--- a/mediagoblin/tests/test_edit.py
+++ b/mediagoblin/tests/test_edit.py
@@ -44,12 +44,12 @@ class TestUserEdit(object):
self.login(test_app)
# Make sure user exists
- assert User.query.filter(LocalUser.username=u'chris').first()
+ assert LocalUser.query.filter(LocalUser.username==u'chris').first()
res = test_app.post('/edit/account/delete/', {'confirmed': 'y'})
# Make sure user has been deleted
- assert User.query.filter(LocalUser.username==u'chris').first() == None
+ assert LocalUser.query.filter(LocalUser.username==u'chris').first() == None
#TODO: make sure all corresponding items comments etc have been
# deleted too. Perhaps in submission test?
@@ -79,7 +79,7 @@ class TestUserEdit(object):
'bio': u'I love toast!',
'url': u'http://dustycloud.org/'})
- test_user = User.query.filter(LocalUser.username==u'chris').first()
+ test_user = LocalUser.query.filter(LocalUser.username==u'chris').first()
assert test_user.bio == u'I love toast!'
assert test_user.url == u'http://dustycloud.org/'
@@ -159,10 +159,10 @@ class TestUserEdit(object):
assert urlparse.urlsplit(res.location)[2] == '/'
# Email shouldn't be saved
- email_in_db = mg_globals.database.User.query.filter(
+ email_in_db = mg_globals.database.LocalUser.query.filter(
LocalUser.email=='new@example.com'
).first()
- email = User.query.filter(LocalUser.username=='chris').first().email
+ email = LocalUser.query.filter(LocalUser.username=='chris').first().email
assert email_in_db is None
assert email == 'chris@example.com'
@@ -173,7 +173,7 @@ class TestUserEdit(object):
res.follow()
# New email saved?
- email = User.query.filter(LocalUser.username=='chris').first().email
+ email = LocalUser.query.filter(LocalUser.username=='chris').first().email
assert email == 'new@example.com'
# test changing the url inproperly