From: Sebastian Spaeth Date: Thu, 20 Dec 2012 23:27:59 +0000 (+0100) Subject: Fix up tests X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=7e55bcb898d37010a5e9bd8a666cd3ddfa63de33;p=mediagoblin.git Fix up tests empty find() queries would not work anymore with the simplified .find compatability code, so remove these and use proper sqlalchemy in the tests. The storage test failed because my virtualenv environment ran mediagoblin/local/mediagoblin/tests/test_storage.py and somehow decided the 2 classes are different objects. Just test against the full class name. Signed-off-by: Sebastian Spaeth --- diff --git a/mediagoblin/tests/test_auth.py b/mediagoblin/tests/test_auth.py index 1b84b435..da17554b 100644 --- a/mediagoblin/tests/test_auth.py +++ b/mediagoblin/tests/test_auth.py @@ -19,9 +19,10 @@ import datetime from nose.tools import assert_equal +from mediagoblin import mg_globals from mediagoblin.auth import lib as auth_lib +from mediagoblin.db.sql.models import User from mediagoblin.tests.tools import setup_fresh_app, fixture_add_user -from mediagoblin import mg_globals from mediagoblin.tools import template, mail @@ -124,7 +125,7 @@ def test_register_views(test_app): u'Invalid email address.'] ## At this point there should be no users in the database ;) - assert not mg_globals.database.User.find().count() + assert not User.query.count() # Successful register # ------------------- diff --git a/mediagoblin/tests/test_storage.py b/mediagoblin/tests/test_storage.py index 6fc2e57c..61326ae9 100644 --- a/mediagoblin/tests/test_storage.py +++ b/mediagoblin/tests/test_storage.py @@ -18,7 +18,7 @@ import os import tempfile -from nose.tools import assert_raises +from nose.tools import assert_raises, assert_equal, assert_true from werkzeug.utils import secure_filename from mediagoblin import storage @@ -78,9 +78,10 @@ def test_storage_system_from_config(): 'garbage_arg': 'garbage_arg', 'storage_class': 'mediagoblin.tests.test_storage:FakeStorageSystem'}) - assert this_storage.foobie == 'eiboof' - assert this_storage.blech == 'hcelb' - assert this_storage.__class__ is FakeStorageSystem + assert_equal(this_storage.foobie, 'eiboof') + assert_equal(this_storage.blech, 'hcelb') + assert_equal(unicode(this_storage.__class__), + u'mediagoblin.tests.test_storage.FakeStorageSystem') ########################## diff --git a/mediagoblin/tests/test_tests.py b/mediagoblin/tests/test_tests.py index 20832ac7..2228d15a 100644 --- a/mediagoblin/tests/test_tests.py +++ b/mediagoblin/tests/test_tests.py @@ -14,9 +14,9 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from mediagoblin.tests.tools import get_test_app - from mediagoblin import mg_globals +from mediagoblin.tests.tools import get_test_app +from mediagoblin.db.sql.models import User def test_get_test_app_wipes_db(): @@ -24,15 +24,15 @@ def test_get_test_app_wipes_db(): Make sure we get a fresh database on every wipe :) """ get_test_app() - assert mg_globals.database.User.find().count() == 0 + assert User.query.count() == 0 new_user = mg_globals.database.User() new_user.username = u'lolcat' new_user.email = u'lol@cats.example.org' new_user.pw_hash = u'pretend_this_is_a_hash' new_user.save() - assert mg_globals.database.User.find().count() == 1 + assert User.query.count() == 1 get_test_app() - assert mg_globals.database.User.find().count() == 0 + assert User.query.count() == 0