From b4997540dcc7b75441e9b10ee6dcac32cc2708be Mon Sep 17 00:00:00 2001 From: Jessica Tallon Date: Mon, 24 Aug 2015 18:28:41 +0200 Subject: 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. --- mediagoblin/tests/test_basic_auth.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'mediagoblin/tests/test_basic_auth.py') diff --git a/mediagoblin/tests/test_basic_auth.py b/mediagoblin/tests/test_basic_auth.py index 0d698a20..3a42e407 100644 --- a/mediagoblin/tests/test_basic_auth.py +++ b/mediagoblin/tests/test_basic_auth.py @@ -88,7 +88,7 @@ def test_change_password(test_app): assert urlparse.urlsplit(res.location)[2] == '/edit/account/' # test_user has to be fetched again in order to have the current values - test_user = User.query.filter(LocalUser.username==u'chris').first() + test_user = LocalUser.query.filter(LocalUser.username==u'chris').first() assert auth_tools.bcrypt_check_password('123456', test_user.pw_hash) # test that the password cannot be changed if the given @@ -100,5 +100,5 @@ def test_change_password(test_app): 'new_password': '098765', }) - test_user = User.query.filter(LocalUser.username==u'chris').first() + test_user = LocalUser.query.filter(LocalUser.username==u'chris').first() assert not auth_tools.bcrypt_check_password('098765', test_user.pw_hash) -- cgit v1.2.3