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 <Sebastian@SSpaeth.de>
This commit is contained in:
Sebastian Spaeth 2012-12-21 00:27:59 +01:00
parent 5c99cd01a7
commit 7e55bcb898
3 changed files with 14 additions and 12 deletions

View File

@ -19,9 +19,10 @@ import datetime
from nose.tools import assert_equal
from mediagoblin.auth import lib as auth_lib
from mediagoblin.tests.tools import setup_fresh_app, fixture_add_user
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.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
# -------------------

View File

@ -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')
##########################

View File

@ -14,9 +14,9 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
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