+++ /dev/null
-# GNU MediaGoblin -- federated, autonomous media hosting
-# Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# 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/>.
-
-import os
-
-from mediagoblin.tests.tools import TEST_APP_CONFIG
-from mediagoblin.init.celery.from_celery import setup_self
-
-
-OUR_MODULENAME = __name__
-CELERY_SETUP = False
-
-
-if os.environ.get('CELERY_CONFIG_MODULE') == OUR_MODULENAME:
- if CELERY_SETUP:
- pass
- else:
- setup_self(check_environ_for_conf=False, module_name=OUR_MODULENAME,
- default_conf_file=TEST_APP_CONFIG)
- CELERY_SETUP = True
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
# 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]
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__'
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):
"""
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.
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()
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.
fi
-CELERY_CONFIG_MODULE=mediagoblin.init.celery.from_tests
-export CELERY_CONFIG_MODULE
-echo "+ CELERY_CONFIG_MODULE=$CELERY_CONFIG_MODULE"
-
# Look to see if the user has specified a specific directory/file to
# run tests out of. If not we'll need to pass along
# mediagoblin/tests/ later very specifically. Otherwise py.test