Really removing nosetests things now! all assert_whatever removed

This commit is contained in:
Christopher Allan Webber 2013-04-06 10:07:47 -05:00
parent 4412385394
commit 7d503a897b
11 changed files with 75 additions and 96 deletions

View File

@ -44,7 +44,6 @@ EVIL_PNG = resource('evil.png')
BIG_BLUE = resource('bigblue.png') BIG_BLUE = resource('bigblue.png')
@pytest.mark.usefixtures("test_app")
class TestAPI(object): class TestAPI(object):
def setup(self): def setup(self):
self.db = mg_globals.database self.db = mg_globals.database

View File

@ -17,8 +17,6 @@
import urlparse import urlparse
import datetime import datetime
from nose.tools import assert_equal
from mediagoblin import mg_globals from mediagoblin import mg_globals
from mediagoblin.auth import lib as auth_lib from mediagoblin.auth import lib as auth_lib
from mediagoblin.db.models import User from mediagoblin.db.models import User
@ -101,8 +99,8 @@ def test_register_views(test_app):
context = template.TEMPLATE_TEST_CONTEXT['mediagoblin/auth/register.html'] context = template.TEMPLATE_TEST_CONTEXT['mediagoblin/auth/register.html']
form = context['register_form'] form = context['register_form']
assert_equal (form.username.errors, [u'Field must be between 3 and 30 characters long.']) assert form.username.errors == [u'Field must be between 3 and 30 characters long.']
assert_equal (form.password.errors, [u'Field must be between 5 and 1024 characters long.']) assert form.password.errors == [u'Field must be between 5 and 1024 characters long.']
## bad form ## bad form
template.clear_test_template_context() template.clear_test_template_context()
@ -113,11 +111,11 @@ def test_register_views(test_app):
context = template.TEMPLATE_TEST_CONTEXT['mediagoblin/auth/register.html'] context = template.TEMPLATE_TEST_CONTEXT['mediagoblin/auth/register.html']
form = context['register_form'] form = context['register_form']
assert_equal (form.username.errors, [u'This field does not take email addresses.']) assert form.username.errors == [u'This field does not take email addresses.']
assert_equal (form.email.errors, [u'This field requires an email address.']) assert form.email.errors == [u'This field requires an email address.']
## At this point there should be no users in the database ;) ## At this point there should be no users in the database ;)
assert_equal(User.query.count(), 0) assert User.query.count() == 0
# Successful register # Successful register
# ------------------- # -------------------
@ -130,9 +128,7 @@ def test_register_views(test_app):
response.follow() response.follow()
## Did we redirect to the proper page? Use the right template? ## Did we redirect to the proper page? Use the right template?
assert_equal( assert urlparse.urlsplit(response.location)[2] == '/u/happygirl/'
urlparse.urlsplit(response.location)[2],
'/u/happygirl/')
assert 'mediagoblin/user_pages/user.html' in template.TEMPLATE_TEST_CONTEXT assert 'mediagoblin/user_pages/user.html' in template.TEMPLATE_TEST_CONTEXT
## Make sure user is in place ## Make sure user is in place
@ -223,9 +219,7 @@ def test_register_views(test_app):
response.follow() response.follow()
## Did we redirect to the proper page? Use the right template? ## Did we redirect to the proper page? Use the right template?
assert_equal( assert urlparse.urlsplit(response.location)[2] == '/auth/login/'
urlparse.urlsplit(response.location)[2],
'/auth/login/')
assert 'mediagoblin/auth/login.html' in template.TEMPLATE_TEST_CONTEXT assert 'mediagoblin/auth/login.html' in template.TEMPLATE_TEST_CONTEXT
## Make sure link to change password is sent by email ## Make sure link to change password is sent by email
@ -256,7 +250,7 @@ def test_register_views(test_app):
response = test_app.get( response = test_app.get(
"/auth/forgot_password/verify/?userid=%s&token=total_bs" % unicode( "/auth/forgot_password/verify/?userid=%s&token=total_bs" % unicode(
new_user.id), status=404) new_user.id), status=404)
assert_equal(response.status.split()[0], u'404') # status="404 NOT FOUND" assert response.status.split()[0] == u'404' # status="404 NOT FOUND"
## Try using an expired token to change password, shouldn't work ## Try using an expired token to change password, shouldn't work
template.clear_test_template_context() template.clear_test_template_context()
@ -265,7 +259,7 @@ def test_register_views(test_app):
new_user.fp_token_expire = datetime.datetime.now() new_user.fp_token_expire = datetime.datetime.now()
new_user.save() new_user.save()
response = test_app.get("%s?%s" % (path, get_params), status=404) response = test_app.get("%s?%s" % (path, get_params), status=404)
assert_equal(response.status.split()[0], u'404') # status="404 NOT FOUND" assert response.status.split()[0] == u'404' # status="404 NOT FOUND"
new_user.fp_token_expire = real_token_expiration new_user.fp_token_expire = real_token_expiration
new_user.save() new_user.save()
@ -293,9 +287,7 @@ def test_register_views(test_app):
# User should be redirected # User should be redirected
response.follow() response.follow()
assert_equal( assert urlparse.urlsplit(response.location)[2] == '/'
urlparse.urlsplit(response.location)[2],
'/')
assert 'mediagoblin/root.html' in template.TEMPLATE_TEST_CONTEXT assert 'mediagoblin/root.html' in template.TEMPLATE_TEST_CONTEXT
@ -370,9 +362,7 @@ def test_authentication_views(test_app):
# User should be redirected # User should be redirected
response.follow() response.follow()
assert_equal( assert urlparse.urlsplit(response.location)[2] == '/'
urlparse.urlsplit(response.location)[2],
'/')
assert 'mediagoblin/root.html' in template.TEMPLATE_TEST_CONTEXT assert 'mediagoblin/root.html' in template.TEMPLATE_TEST_CONTEXT
# Make sure user is in the session # Make sure user is in the session
@ -387,9 +377,7 @@ def test_authentication_views(test_app):
# Should be redirected to index page # Should be redirected to index page
response.follow() response.follow()
assert_equal( assert urlparse.urlsplit(response.location)[2] == '/'
urlparse.urlsplit(response.location)[2],
'/')
assert 'mediagoblin/root.html' in template.TEMPLATE_TEST_CONTEXT assert 'mediagoblin/root.html' in template.TEMPLATE_TEST_CONTEXT
# Make sure the user is not in the session # Make sure the user is not in the session
@ -405,6 +393,4 @@ def test_authentication_views(test_app):
'username': u'chris', 'username': u'chris',
'password': 'toast', 'password': 'toast',
'next' : '/u/chris/'}) 'next' : '/u/chris/'})
assert_equal( assert urlparse.urlsplit(response.location)[2] == '/u/chris/'
urlparse.urlsplit(response.location)[2],
'/u/chris/')

View File

@ -16,7 +16,6 @@
from mediagoblin.tests.tools import fixture_add_collection, fixture_add_user from mediagoblin.tests.tools import fixture_add_collection, fixture_add_user
from mediagoblin.db.models import Collection, User from mediagoblin.db.models import Collection, User
from nose.tools import assert_equal
def test_user_deletes_collection(test_app): def test_user_deletes_collection(test_app):
@ -30,4 +29,4 @@ def test_user_deletes_collection(test_app):
user.delete() user.delete()
cnt2 = Collection.query.count() cnt2 = Collection.query.count()
assert_equal(cnt1, cnt2 + 1) assert cnt1 == cnt2 + 1

View File

@ -14,7 +14,7 @@
# You should have received a copy of the GNU Affero General Public License # 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/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
from nose.tools import assert_equal import pytest
from mediagoblin import mg_globals from mediagoblin import mg_globals
from mediagoblin.db.models import User from mediagoblin.db.models import User
@ -69,7 +69,7 @@ class TestUserEdit(object):
}) })
# Check for redirect on success # Check for redirect on success
assert_equal(res.status_int, 302) assert res.status_int == 302
# test_user has to be fetched again in order to have the current values # test_user has to be fetched again in order to have the current values
test_user = User.query.filter_by(username=u'chris').first() test_user = User.query.filter_by(username=u'chris').first()
assert bcrypt_check_password('123456', test_user.pw_hash) assert bcrypt_check_password('123456', test_user.pw_hash)
@ -99,7 +99,7 @@ class TestUserEdit(object):
'url': u'http://dustycloud.org/'}, expect_errors=True) 'url': u'http://dustycloud.org/'}, expect_errors=True)
# Should redirect to /u/chris/edit/ # Should redirect to /u/chris/edit/
assert_equal (res.status_int, 302) assert res.status_int == 302
assert res.headers['Location'].endswith("/u/chris/edit/") assert res.headers['Location'].endswith("/u/chris/edit/")
res = test_app.post( res = test_app.post(
@ -108,8 +108,8 @@ class TestUserEdit(object):
'url': u'http://dustycloud.org/'}) 'url': u'http://dustycloud.org/'})
test_user = User.query.filter_by(username=u'chris').first() test_user = User.query.filter_by(username=u'chris').first()
assert_equal(test_user.bio, u'I love toast!') assert test_user.bio == u'I love toast!'
assert_equal(test_user.url, u'http://dustycloud.org/') assert test_user.url == u'http://dustycloud.org/'
# change a different user than the logged in (should fail with 403) # change a different user than the logged in (should fail with 403)
fixture_add_user(username=u"foo") fixture_add_user(username=u"foo")
@ -117,7 +117,7 @@ class TestUserEdit(object):
'/u/foo/edit/', { '/u/foo/edit/', {
'bio': u'I love toast!', 'bio': u'I love toast!',
'url': u'http://dustycloud.org/'}, expect_errors=True) 'url': u'http://dustycloud.org/'}, expect_errors=True)
assert_equal(res.status_int, 403) assert res.status_int == 403
# test changing the bio and the URL inproperly # test changing the bio and the URL inproperly
too_long_bio = 150 * 'T' + 150 * 'o' + 150 * 'a' + 150 * 's' + 150* 't' too_long_bio = 150 * 'T' + 150 * 'o' + 150 * 'a' + 150 * 's' + 150* 't'
@ -129,10 +129,13 @@ class TestUserEdit(object):
'url': 'this-is-no-url'}) 'url': 'this-is-no-url'})
# Check form errors # Check form errors
context = template.TEMPLATE_TEST_CONTEXT['mediagoblin/edit/edit_profile.html'] context = template.TEMPLATE_TEST_CONTEXT[
'mediagoblin/edit/edit_profile.html']
form = context['form'] form = context['form']
assert_equal(form.bio.errors, [u'Field must be between 0 and 500 characters long.']) assert form.bio.errors == [
assert_equal(form.url.errors, [u'This address contains errors']) u'Field must be between 0 and 500 characters long.']
assert form.url.errors == [
u'This address contains errors']
# test changing the url inproperly # test changing the url inproperly

View File

@ -14,7 +14,7 @@
# You should have received a copy of the GNU Affero General Public License # 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/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
from nose.tools import assert_raises import pytest
from mediagoblin import mg_globals from mediagoblin import mg_globals
@ -36,7 +36,7 @@ class TestGlobals(object):
assert mg_globals.public_store == 'my favorite public_store!' assert mg_globals.public_store == 'my favorite public_store!'
assert mg_globals.queue_store == 'my favorite queue_store!' assert mg_globals.queue_store == 'my favorite queue_store!'
assert_raises( pytest.raises(
AssertionError, AssertionError,
mg_globals.setup_globals, mg_globals.setup_globals,
no_such_global_foo = "Dummy") no_such_global_foo="Dummy")

View File

@ -14,8 +14,6 @@
# You should have received a copy of the GNU Affero General Public License # 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/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
from nose.tools import assert_equal
from mediagoblin.db.base import Session from mediagoblin.db.base import Session
from mediagoblin.db.models import User, MediaEntry, MediaComment from mediagoblin.db.models import User, MediaEntry, MediaComment
from mediagoblin.tests.tools import fixture_add_user, fixture_media_entry from mediagoblin.tests.tools import fixture_add_user, fixture_media_entry
@ -23,7 +21,7 @@ from mediagoblin.tests.tools import fixture_add_user, fixture_media_entry
def test_404_for_non_existent(test_app): def test_404_for_non_existent(test_app):
res = test_app.get('/does-not-exist/', expect_errors=True) res = test_app.get('/does-not-exist/', expect_errors=True)
assert_equal(res.status_int, 404) assert res.status_int == 404
def test_user_deletes_other_comments(test_app): def test_user_deletes_other_comments(test_app):
@ -58,11 +56,11 @@ def test_user_deletes_other_comments(test_app):
cmt_cnt2 = MediaComment.query.count() cmt_cnt2 = MediaComment.query.count()
# One user deleted # One user deleted
assert_equal(usr_cnt2, usr_cnt1 - 1) assert usr_cnt2 == usr_cnt1 - 1
# One media gone # One media gone
assert_equal(med_cnt2, med_cnt1 - 1) assert med_cnt2 == med_cnt1 - 1
# Three of four comments gone. # Three of four comments gone.
assert_equal(cmt_cnt2, cmt_cnt1 - 3) assert cmt_cnt2 == cmt_cnt1 - 3
User.query.get(user_b.id).delete() User.query.get(user_b.id).delete()
@ -71,11 +69,11 @@ def test_user_deletes_other_comments(test_app):
cmt_cnt2 = MediaComment.query.count() cmt_cnt2 = MediaComment.query.count()
# All users gone # All users gone
assert_equal(usr_cnt2, usr_cnt1 - 2) assert usr_cnt2 == usr_cnt1 - 2
# All media gone # All media gone
assert_equal(med_cnt2, med_cnt1 - 2) assert med_cnt2 == med_cnt1 - 2
# All comments gone # All comments gone
assert_equal(cmt_cnt2, cmt_cnt1 - 4) assert cmt_cnt2 == cmt_cnt1 - 4
def test_media_deletes_broken_attachment(test_app): def test_media_deletes_broken_attachment(test_app):

View File

@ -17,8 +17,6 @@
# Maybe not every model needs a test, but some models have special # Maybe not every model needs a test, but some models have special
# methods, and so it makes sense to test them here. # methods, and so it makes sense to test them here.
from nose.tools import assert_equal
from mediagoblin.db.base import Session from mediagoblin.db.base import Session
from mediagoblin.db.models import MediaEntry from mediagoblin.db.models import MediaEntry
@ -166,4 +164,4 @@ def test_media_data_init(test_app):
for obj in Session(): for obj in Session():
obj_in_session += 1 obj_in_session += 1
print repr(obj) print repr(obj)
assert_equal(obj_in_session, 0) assert obj_in_session == 0

View File

@ -19,7 +19,6 @@ from configobj import ConfigObj
from mediagoblin import mg_globals from mediagoblin import mg_globals
from mediagoblin.init.plugins import setup_plugins from mediagoblin.init.plugins import setup_plugins
from mediagoblin.tools import pluginapi from mediagoblin.tools import pluginapi
from nose.tools import eq_
def with_cleanup(*modules_to_delete): def with_cleanup(*modules_to_delete):
@ -97,7 +96,7 @@ def test_no_plugins():
setup_plugins() setup_plugins()
# Make sure we didn't load anything. # Make sure we didn't load anything.
eq_(len(pman.plugins), 0) assert len(pman.plugins) == 0
@with_cleanup('mediagoblin.plugins.sampleplugin') @with_cleanup('mediagoblin.plugins.sampleplugin')
@ -117,14 +116,14 @@ def test_one_plugin():
setup_plugins() setup_plugins()
# Make sure we only found one plugin # Make sure we only found one plugin
eq_(len(pman.plugins), 1) assert len(pman.plugins) == 1
# Make sure the plugin is the one we think it is. # Make sure the plugin is the one we think it is.
eq_(pman.plugins[0], 'mediagoblin.plugins.sampleplugin') assert pman.plugins[0] == 'mediagoblin.plugins.sampleplugin'
# Make sure there was one hook registered # Make sure there was one hook registered
eq_(len(pman.hooks), 1) assert len(pman.hooks) == 1
# Make sure _setup_plugin_called was called once # Make sure _setup_plugin_called was called once
import mediagoblin.plugins.sampleplugin import mediagoblin.plugins.sampleplugin
eq_(mediagoblin.plugins.sampleplugin._setup_plugin_called, 1) assert mediagoblin.plugins.sampleplugin._setup_plugin_called == 1
@with_cleanup('mediagoblin.plugins.sampleplugin') @with_cleanup('mediagoblin.plugins.sampleplugin')
@ -145,14 +144,14 @@ def test_same_plugin_twice():
setup_plugins() setup_plugins()
# Make sure we only found one plugin # Make sure we only found one plugin
eq_(len(pman.plugins), 1) assert len(pman.plugins) == 1
# Make sure the plugin is the one we think it is. # Make sure the plugin is the one we think it is.
eq_(pman.plugins[0], 'mediagoblin.plugins.sampleplugin') assert pman.plugins[0] == 'mediagoblin.plugins.sampleplugin'
# Make sure there was one hook registered # Make sure there was one hook registered
eq_(len(pman.hooks), 1) assert len(pman.hooks) == 1
# Make sure _setup_plugin_called was called once # Make sure _setup_plugin_called was called once
import mediagoblin.plugins.sampleplugin import mediagoblin.plugins.sampleplugin
eq_(mediagoblin.plugins.sampleplugin._setup_plugin_called, 1) assert mediagoblin.plugins.sampleplugin._setup_plugin_called == 1
@with_cleanup() @with_cleanup()
@ -172,4 +171,4 @@ def test_disabled_plugin():
setup_plugins() setup_plugins()
# Make sure we didn't load the plugin # Make sure we didn't load the plugin
eq_(len(pman.plugins), 0) assert len(pman.plugins) == 0

View File

@ -18,7 +18,7 @@
import os import os
import tempfile import tempfile
from nose.tools import assert_raises, assert_equal, assert_true import pytest
from werkzeug.utils import secure_filename from werkzeug.utils import secure_filename
from mediagoblin import storage from mediagoblin import storage
@ -41,10 +41,8 @@ def test_clean_listy_filepath():
assert storage.clean_listy_filepath( assert storage.clean_listy_filepath(
['../../../etc/', 'passwd']) == expected ['../../../etc/', 'passwd']) == expected
assert_raises( with pytest.raises(storage.InvalidFilepath):
storage.InvalidFilepath, storage.clean_listy_filepath(['../../', 'linooks.jpg'])
storage.clean_listy_filepath,
['../../', 'linooks.jpg'])
class FakeStorageSystem(): class FakeStorageSystem():
@ -78,10 +76,10 @@ def test_storage_system_from_config():
'garbage_arg': 'garbage_arg', 'garbage_arg': 'garbage_arg',
'storage_class': 'storage_class':
'mediagoblin.tests.test_storage:FakeStorageSystem'}) 'mediagoblin.tests.test_storage:FakeStorageSystem'})
assert_equal(this_storage.foobie, 'eiboof') assert this_storage.foobie == 'eiboof'
assert_equal(this_storage.blech, 'hcelb') assert this_storage.blech == 'hcelb'
assert_equal(unicode(this_storage.__class__), assert unicode(this_storage.__class__) == \
u'mediagoblin.tests.test_storage.FakeStorageSystem') u'mediagoblin.tests.test_storage.FakeStorageSystem'
########################## ##########################
@ -108,7 +106,7 @@ def test_basic_storage__resolve_filepath():
assert result == os.path.join( assert result == os.path.join(
tmpdir, 'etc/passwd') tmpdir, 'etc/passwd')
assert_raises( pytest.raises(
storage.InvalidFilepath, storage.InvalidFilepath,
this_storage._resolve_filepath, this_storage._resolve_filepath,
['../../', 'etc', 'passwd']) ['../../', 'etc', 'passwd'])
@ -205,7 +203,7 @@ def test_basic_storage_delete_file():
def test_basic_storage_url_for_file(): def test_basic_storage_url_for_file():
# Not supplying a base_url should actually just bork. # Not supplying a base_url should actually just bork.
tmpdir, this_storage = get_tmp_filestorage() tmpdir, this_storage = get_tmp_filestorage()
assert_raises( pytest.raises(
storage.NoWebServing, storage.NoWebServing,
this_storage.file_url, this_storage.file_url,
['dir1', 'dir2', 'filename.txt']) ['dir1', 'dir2', 'filename.txt'])

View File

@ -21,7 +21,6 @@ sys.setdefaultencoding('utf-8')
import urlparse import urlparse
import os import os
from nose.tools import assert_equal, assert_true
from pkg_resources import resource_filename from pkg_resources import resource_filename
from mediagoblin.tests.tools import fixture_add_user from mediagoblin.tests.tools import fixture_add_user
@ -87,7 +86,7 @@ class TestSubmission:
def check_comments(self, request, media_id, count): def check_comments(self, request, media_id, count):
comments = request.db.MediaComment.find({'media_entry': media_id}) comments = request.db.MediaComment.find({'media_entry': media_id})
assert_equal(count, len(list(comments))) assert count == len(list(comments))
def test_missing_fields(self, test_app): def test_missing_fields(self, test_app):
self._setup(test_app) self._setup(test_app)
@ -95,21 +94,21 @@ class TestSubmission:
# Test blank form # Test blank form
# --------------- # ---------------
response, form = self.do_post({}, *FORM_CONTEXT) response, form = self.do_post({}, *FORM_CONTEXT)
assert_equal(form.file.errors, [u'You must provide a file.']) assert form.file.errors == [u'You must provide a file.']
# Test blank file # Test blank file
# --------------- # ---------------
response, form = self.do_post({'title': u'test title'}, *FORM_CONTEXT) response, form = self.do_post({'title': u'test title'}, *FORM_CONTEXT)
assert_equal(form.file.errors, [u'You must provide a file.']) assert form.file.errors == [u'You must provide a file.']
def check_url(self, response, path): def check_url(self, response, path):
assert_equal(urlparse.urlsplit(response.location)[2], path) assert urlparse.urlsplit(response.location)[2] == path
def check_normal_upload(self, title, filename): def check_normal_upload(self, title, filename):
response, context = self.do_post({'title': title}, do_follow=True, response, context = self.do_post({'title': title}, do_follow=True,
**self.upload_data(filename)) **self.upload_data(filename))
self.check_url(response, '/u/{0}/'.format(self.test_user.username)) self.check_url(response, '/u/{0}/'.format(self.test_user.username))
assert_true('mediagoblin/user_pages/user.html' in context) assert 'mediagoblin/user_pages/user.html' in context
# Make sure the media view is at least reachable, logged in... # Make sure the media view is at least reachable, logged in...
url = '/u/{0}/m/{1}/'.format(self.test_user.username, url = '/u/{0}/m/{1}/'.format(self.test_user.username,
title.lower().replace(' ', '-')) title.lower().replace(' ', '-'))
@ -129,7 +128,7 @@ class TestSubmission:
def check_media(self, request, find_data, count=None): def check_media(self, request, find_data, count=None):
media = MediaEntry.find(find_data) media = MediaEntry.find(find_data)
if count is not None: if count is not None:
assert_equal(media.count(), count) assert media.count() == count
if count == 0: if count == 0:
return return
return media[0] return media[0]
@ -156,10 +155,10 @@ class TestSubmission:
'tags': BAD_TAG_STRING}, 'tags': BAD_TAG_STRING},
*FORM_CONTEXT, *FORM_CONTEXT,
**self.upload_data(GOOD_JPG)) **self.upload_data(GOOD_JPG))
assert_equal(form.tags.errors, [ assert form.tags.errors == [
u'Tags must be shorter than 50 characters. ' \ u'Tags must be shorter than 50 characters. ' \
'Tags that are too long: ' \ 'Tags that are too long: ' \
'ffffffffffffffffffffffffffuuuuuuuuuuuuuuuuuuuuuuuuuu']) 'ffffffffffffffffffffffffffuuuuuuuuuuuuuuuuuuuuuuuuuu']
def test_delete(self, test_app): def test_delete(self, test_app):
self._setup(test_app) self._setup(test_app)
@ -180,7 +179,7 @@ class TestSubmission:
'slug': u"Balanced=Goblin", 'slug': u"Balanced=Goblin",
'tags': u''}) 'tags': u''})
media = self.check_media(request, {'title': u'Balanced Goblin'}, 1) media = self.check_media(request, {'title': u'Balanced Goblin'}, 1)
assert_equal(media.slug, u"balanced-goblin") assert media.slug == u"balanced-goblin"
# Add a comment, so we can test for its deletion later. # Add a comment, so we can test for its deletion later.
self.check_comments(request, media_id, 0) self.check_comments(request, media_id, 0)
@ -216,7 +215,7 @@ class TestSubmission:
response, form = self.do_post({'title': u'Malicious Upload 1'}, response, form = self.do_post({'title': u'Malicious Upload 1'},
*FORM_CONTEXT, *FORM_CONTEXT,
**self.upload_data(EVIL_FILE)) **self.upload_data(EVIL_FILE))
assert_equal(len(form.file.errors), 1) assert len(form.file.errors) == 1
assert 'Sorry, I don\'t support that file type :(' == \ assert 'Sorry, I don\'t support that file type :(' == \
str(form.file.errors[0]) str(form.file.errors[0])
@ -231,8 +230,8 @@ class TestSubmission:
**self.upload_data(GOOD_JPG)) **self.upload_data(GOOD_JPG))
media = self.check_media(request, {'title': u'Balanced Goblin'}, 1) media = self.check_media(request, {'title': u'Balanced Goblin'}, 1)
assert_equal(media.media_type, u'mediagoblin.media_types.image') assert media.media_type == u'mediagoblin.media_types.image'
assert_equal(media.media_manager, img_MEDIA_MANAGER) assert media.media_manager == img_MEDIA_MANAGER
def test_sniffing(self, test_app): def test_sniffing(self, test_app):
@ -267,8 +266,8 @@ class TestSubmission:
**self.upload_data(filename)) **self.upload_data(filename))
self.check_url(response, '/u/{0}/'.format(self.test_user.username)) self.check_url(response, '/u/{0}/'.format(self.test_user.username))
entry = mg_globals.database.MediaEntry.find_one({'title': title}) entry = mg_globals.database.MediaEntry.find_one({'title': title})
assert_equal(entry.state, 'failed') assert entry.state == 'failed'
assert_equal(entry.fail_error, u'mediagoblin.processing:BadMediaFail') assert entry.fail_error == u'mediagoblin.processing:BadMediaFail'
def test_evil_jpg(self, test_app): def test_evil_jpg(self, test_app):
self._setup(test_app) self._setup(test_app)
@ -289,7 +288,7 @@ class TestSubmission:
self.check_normal_upload(u"With GPS data", GPS_JPG) self.check_normal_upload(u"With GPS data", GPS_JPG)
media = self.check_media(None, {"title": u"With GPS data"}, 1) media = self.check_media(None, {"title": u"With GPS data"}, 1)
assert_equal(media.media_data.gps_latitude, 59.336666666666666) assert media.media_data.gps_latitude == 59.336666666666666
def test_processing(self, test_app): def test_processing(self, test_app):
self._setup(test_app) self._setup(test_app)
@ -309,8 +308,8 @@ class TestSubmission:
filename = os.path.join( filename = os.path.join(
public_store_dir, public_store_dir,
*media.media_files.get(key, [])) *media.media_files.get(key, []))
assert_true(filename.endswith('_' + basename)) assert filename.endswith('_' + basename)
# Is it smaller than the last processed image we looked at? # Is it smaller than the last processed image we looked at?
size = os.stat(filename).st_size size = os.stat(filename).st_size
assert_true(last_size > size) assert last_size > size
last_size = size last_size = size

View File

@ -50,9 +50,9 @@ USER_DEV_DIRECTORIES_TO_SETUP = [
'beaker/sessions/data', 'beaker/sessions/lock'] 'beaker/sessions/data', 'beaker/sessions/lock']
BAD_CELERY_MESSAGE = """\ BAD_CELERY_MESSAGE = """\
Sorry, you *absolutely* must run nosetests with the Sorry, you *absolutely* must run tests with the
mediagoblin.init.celery.from_tests module. Like so: mediagoblin.init.celery.from_tests module. Like so:
$ CELERY_CONFIG_MODULE=mediagoblin.init.celery.from_tests ./bin/nosetests""" $ CELERY_CONFIG_MODULE=mediagoblin.init.celery.from_tests ./bin/py.test"""
class BadCeleryEnviron(Exception): pass class BadCeleryEnviron(Exception): pass