aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/tests
diff options
context:
space:
mode:
authorChristopher Allan Webber <cwebber@dustycloud.org>2013-05-12 16:17:35 -0500
committerChristopher Allan Webber <cwebber@dustycloud.org>2013-05-12 16:17:35 -0500
commit725404236ef66884e53e0ef83264524768cefb9c (patch)
tree6fe10bc1a8b3e7fcb30cc0c1347334251d5337c9 /mediagoblin/tests
parent98dacfe67e40eb3c575b2fb9a5a80ced3e284ddc (diff)
parent2dee97ef4828c313c9934f1d36986ecb363ef6e4 (diff)
downloadmediagoblin-725404236ef66884e53e0ef83264524768cefb9c.tar.lz
mediagoblin-725404236ef66884e53e0ef83264524768cefb9c.tar.xz
mediagoblin-725404236ef66884e53e0ef83264524768cefb9c.zip
Merge branch 'master' into 623_context_hooks
Diffstat (limited to 'mediagoblin/tests')
-rw-r--r--mediagoblin/tests/__init__.py4
-rw-r--r--mediagoblin/tests/test_messages.py16
-rw-r--r--mediagoblin/tests/test_mgoblin_app.ini4
-rw-r--r--mediagoblin/tests/test_processing.py4
-rw-r--r--mediagoblin/tests/tools.py28
5 files changed, 14 insertions, 42 deletions
diff --git a/mediagoblin/tests/__init__.py b/mediagoblin/tests/__init__.py
index 5a3235c6..7a88281e 100644
--- a/mediagoblin/tests/__init__.py
+++ b/mediagoblin/tests/__init__.py
@@ -18,12 +18,10 @@ import os
import shutil
from mediagoblin import mg_globals
-from mediagoblin.tests.tools import (
- TEST_USER_DEV, suicide_if_bad_celery_environ)
+from mediagoblin.tests.tools import TEST_USER_DEV
def setup_package():
- suicide_if_bad_celery_environ()
import warnings
from sqlalchemy.exc import SAWarning
diff --git a/mediagoblin/tests/test_messages.py b/mediagoblin/tests/test_messages.py
index 3ac917b0..22f9e800 100644
--- a/mediagoblin/tests/test_messages.py
+++ b/mediagoblin/tests/test_messages.py
@@ -14,7 +14,7 @@
# 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.messages import fetch_messages, add_message
+from mediagoblin import messages
from mediagoblin.tools import template
@@ -32,11 +32,19 @@ def test_messages(test_app):
# The message queue should be empty
assert request.session.get('messages', []) == []
+ # First of all, we should clear the messages queue
+ messages.clear_add_message()
# Adding a message should modify the session accordingly
- add_message(request, 'herp_derp', 'First!')
+ messages.add_message(request, 'herp_derp', 'First!')
test_msg_queue = [{'text': 'First!', 'level': 'herp_derp'}]
- assert request.session['messages'] == test_msg_queue
+
+ # Alternative tests to the following, test divided in two steps:
+ # assert request.session['messages'] == test_msg_queue
+ # 1. Tests if add_message worked
+ assert messages.ADD_MESSAGE_TEST[-1] == test_msg_queue
+ # 2. Tests if add_message updated session information
+ assert messages.ADD_MESSAGE_TEST[-1] == request.session['messages']
# fetch_messages should return and empty the queue
- assert fetch_messages(request) == test_msg_queue
+ assert messages.fetch_messages(request) == test_msg_queue
assert request.session.get('messages') == []
diff --git a/mediagoblin/tests/test_mgoblin_app.ini b/mediagoblin/tests/test_mgoblin_app.ini
index 9f95a398..8c668356 100644
--- a/mediagoblin/tests/test_mgoblin_app.ini
+++ b/mediagoblin/tests/test_mgoblin_app.ini
@@ -12,10 +12,6 @@ tags_max_length = 50
# So we can start to test attachments:
allow_attachments = True
-# Celery shouldn't be set up by the application as it's setup via
-# mediagoblin.init.celery.from_celery
-celery_setup_elsewhere = true
-
media_types = mediagoblin.media_types.image, mediagoblin.media_types.pdf
[storage:publicstore]
diff --git a/mediagoblin/tests/test_processing.py b/mediagoblin/tests/test_processing.py
index fe8489aa..591add96 100644
--- a/mediagoblin/tests/test_processing.py
+++ b/mediagoblin/tests/test_processing.py
@@ -1,7 +1,5 @@
#!/usr/bin/env python
-from nose.tools import assert_equal
-
from mediagoblin import processing
class TestProcessing(object):
@@ -10,7 +8,7 @@ class TestProcessing(object):
result = builder.fill(format)
if output is None:
return result
- assert_equal(output, result)
+ assert output == result
def test_easy_filename_fill(self):
self.run_fill('/home/user/foo.TXT', '{basename}bar{ext}', 'foobar.txt')
diff --git a/mediagoblin/tests/tools.py b/mediagoblin/tests/tools.py
index 52635e18..794ed940 100644
--- a/mediagoblin/tests/tools.py
+++ b/mediagoblin/tests/tools.py
@@ -33,7 +33,6 @@ from mediagoblin.db.base import Session
from mediagoblin.meddleware import BaseMeddleware
from mediagoblin.auth.lib import bcrypt_gen_password_hash
from mediagoblin.gmg_commands.dbupdate import run_dbupdate
-from mediagoblin.init.celery import setup_celery_app
MEDIAGOBLIN_TEST_DB_NAME = u'__mediagoblin_tests__'
@@ -47,16 +46,6 @@ TEST_USER_DEV = pkg_resources.resource_filename(
USER_DEV_DIRECTORIES_TO_SETUP = ['media/public', 'media/queue']
-BAD_CELERY_MESSAGE = """\
-Sorry, you *absolutely* must run tests with the
-mediagoblin.init.celery.from_tests module. Like so:
-
-$ CELERY_CONFIG_MODULE=mediagoblin.init.celery.from_tests {0}
-""".format(sys.argv[0])
-
-
-class BadCeleryEnviron(Exception): pass
-
class TestingMeddleware(BaseMeddleware):
"""
@@ -97,12 +86,6 @@ class TestingMeddleware(BaseMeddleware):
return
-def suicide_if_bad_celery_environ():
- if not os.environ.get('CELERY_CONFIG_MODULE') == \
- 'mediagoblin.init.celery.from_tests':
- raise BadCeleryEnviron(BAD_CELERY_MESSAGE)
-
-
def get_app(request, paste_config=None, mgoblin_config=None):
"""Create a MediaGoblin app for testing.
@@ -127,14 +110,6 @@ def get_app(request, paste_config=None, mgoblin_config=None):
shutil.copyfile(paste_config, new_paste_config)
shutil.copyfile(mgoblin_config, new_mgoblin_config)
- suicide_if_bad_celery_environ()
-
- # Make sure we've turned on testing
- testing._activate_testing()
-
- # Leave this imported as it sets up celery.
- from mediagoblin.init.celery import from_tests
-
Session.rollback()
Session.remove()
@@ -154,9 +129,6 @@ def get_app(request, paste_config=None, mgoblin_config=None):
test_app = loadapp(
'config:' + new_paste_config)
- # Re-setup celery
- setup_celery_app(app_config, global_config)
-
# Insert the TestingMeddleware, which can do some
# sanity checks on every request/response.
# Doing it this way is probably not the cleanest way.