Use urljoin to create proper feed media URLs
[larjonas-mediagoblin.git] / mediagoblin / tests / test_celery_setup.py
blobdf0d04b0ce9add3d339a647d13a5bc2e304754cc
1 # GNU MediaGoblin -- federated, autonomous media hosting
2 # Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS.
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU Affero General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU Affero General Public License for more details.
14 # You should have received a copy of the GNU Affero General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 import pkg_resources
19 from mediagoblin.init import celery as celery_setup
20 from mediagoblin.init.config import read_mediagoblin_config
23 TEST_CELERY_CONF_NOSPECIALDB = pkg_resources.resource_filename(
24 'mediagoblin.tests', 'fake_celery_conf.ini')
27 def test_setup_celery_from_config():
28 def _wipe_testmodule_clean(module):
29 vars_to_wipe = [
30 var for var in dir(module)
31 if not var.startswith('__') and not var.endswith('__')]
32 for var in vars_to_wipe:
33 delattr(module, var)
35 global_config, validation_result = read_mediagoblin_config(
36 TEST_CELERY_CONF_NOSPECIALDB)
37 app_config = global_config['mediagoblin']
39 celery_setup.setup_celery_from_config(
40 app_config, global_config,
41 'mediagoblin.tests.fake_celery_module', set_environ=False)
43 from mediagoblin.tests import fake_celery_module
44 assert fake_celery_module.SOME_VARIABLE == 'floop'
45 assert fake_celery_module.MAIL_PORT == 2000
46 assert isinstance(fake_celery_module.MAIL_PORT, int)
47 assert fake_celery_module.CELERYD_ETA_SCHEDULER_PRECISION == 1.3
48 assert isinstance(fake_celery_module.CELERYD_ETA_SCHEDULER_PRECISION, float)
49 assert fake_celery_module.CELERY_RESULT_PERSISTENT is True
50 assert fake_celery_module.CELERY_IMPORTS == [
51 'foo.bar.baz', 'this.is.an.import', 'mediagoblin.processing.task', \
52 'mediagoblin.notifications.task', 'mediagoblin.submit.task']
53 assert fake_celery_module.CELERY_RESULT_BACKEND == 'database'
54 assert fake_celery_module.CELERY_RESULT_DBURI == (
55 'sqlite:///' +
56 pkg_resources.resource_filename('mediagoblin.tests', 'celery.db'))
58 assert fake_celery_module.BROKER_TRANSPORT == 'sqlalchemy'
59 assert fake_celery_module.BROKER_URL == (
60 'sqlite:///' +
61 pkg_resources.resource_filename('mediagoblin.tests', 'kombu.db'))