Preparing celery unit tests for new setup.
Instead of the previous passing in of dictionaries, we're actually checking some example config files.
This commit is contained in:
parent
72c3ae046a
commit
8abeaf2fb6
@ -1,4 +1,9 @@
|
|||||||
[mediagoblin]
|
[mediagoblin]
|
||||||
|
# database stuff
|
||||||
|
db_host = string()
|
||||||
|
db_name = string()
|
||||||
|
db_port = integer()
|
||||||
|
|
||||||
#
|
#
|
||||||
queuestore_base_dir = string(default="%(here)s/user_dev/media/queue")
|
queuestore_base_dir = string(default="%(here)s/user_dev/media/queue")
|
||||||
publicstore_base_dir = string(default="%(here)s/user_dev/media/public")
|
publicstore_base_dir = string(default="%(here)s/user_dev/media/public")
|
||||||
|
9
mediagoblin/tests/fake_celery_conf.ini
Normal file
9
mediagoblin/tests/fake_celery_conf.ini
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
['mediagoblin']
|
||||||
|
# I got nothin' in this file!
|
||||||
|
|
||||||
|
['celery']
|
||||||
|
some_variable = floop
|
||||||
|
mail_port = 2000
|
||||||
|
celeryd_eta_scheduler_precision = 1.3
|
||||||
|
celery_result_persistent = true
|
||||||
|
celery_imports = foo.bar.baz, this.is.an.import
|
14
mediagoblin/tests/fake_celery_conf_mgdb.ini
Normal file
14
mediagoblin/tests/fake_celery_conf_mgdb.ini
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
['mediagoblin']
|
||||||
|
db_host = mongodb.example.org
|
||||||
|
db_port = 8080
|
||||||
|
db_name = captain_lollerskates
|
||||||
|
|
||||||
|
['something']
|
||||||
|
or = other
|
||||||
|
|
||||||
|
['celery']
|
||||||
|
some_variable = poolf
|
||||||
|
mail_port = 2020
|
||||||
|
celeryd_eta_scheduler_precision = 3.1
|
||||||
|
celery_result_persistent = false
|
||||||
|
celery_imports = baz.bar.foo, import.is.a.this
|
@ -17,6 +17,13 @@
|
|||||||
import pkg_resources
|
import pkg_resources
|
||||||
|
|
||||||
from mediagoblin import celery_setup
|
from mediagoblin import celery_setup
|
||||||
|
from mediagoblin.config import read_mediagoblin_config
|
||||||
|
|
||||||
|
|
||||||
|
TEST_CELERY_CONF_NOSPECIALDB = pkg_resources.resource_filename(
|
||||||
|
'mediagoblin.tests', 'fake_celery_conf.ini')
|
||||||
|
TEST_CELERY_CONF_MGSPECIALDB = pkg_resources.resource_filename(
|
||||||
|
'mediagoblin.tests', 'fake_celery_conf_mgdb.ini')
|
||||||
|
|
||||||
|
|
||||||
def test_setup_celery_from_config():
|
def test_setup_celery_from_config():
|
||||||
@ -27,14 +34,12 @@ def test_setup_celery_from_config():
|
|||||||
for var in vars_to_wipe:
|
for var in vars_to_wipe:
|
||||||
delattr(module, var)
|
delattr(module, var)
|
||||||
|
|
||||||
|
global_config, validation_result = read_mediagoblin_config(
|
||||||
|
TEST_CELERY_CONF_NOSPECIALDB)
|
||||||
|
app_config = global_config['mediagoblin']
|
||||||
|
|
||||||
celery_setup.setup_celery_from_config(
|
celery_setup.setup_celery_from_config(
|
||||||
{},
|
app_config, global_config,
|
||||||
{'something': {'or': 'other'},
|
|
||||||
'celery': {'some_variable': 'floop',
|
|
||||||
'mail_port': '2000',
|
|
||||||
'CELERYD_ETA_SCHEDULER_PRECISION': '1.3',
|
|
||||||
'celery_result_persistent': 'true',
|
|
||||||
'celery_imports': 'foo.bar.baz this.is.an.import'}},
|
|
||||||
'mediagoblin.tests.fake_celery_module', set_environ=False)
|
'mediagoblin.tests.fake_celery_module', set_environ=False)
|
||||||
|
|
||||||
from mediagoblin.tests import fake_celery_module
|
from mediagoblin.tests import fake_celery_module
|
||||||
@ -53,17 +58,12 @@ def test_setup_celery_from_config():
|
|||||||
|
|
||||||
_wipe_testmodule_clean(fake_celery_module)
|
_wipe_testmodule_clean(fake_celery_module)
|
||||||
|
|
||||||
|
global_config, validation_result = read_mediagoblin_config(
|
||||||
|
TEST_CELERY_CONF_MGSPECIALDB)
|
||||||
|
app_config = global_config['mediagoblin']
|
||||||
|
|
||||||
celery_setup.setup_celery_from_config(
|
celery_setup.setup_celery_from_config(
|
||||||
{'db_host': 'mongodb.example.org',
|
app_config, global_config,
|
||||||
'db_port': '8080',
|
|
||||||
'db_name': 'captain_lollerskates',
|
|
||||||
'celery_section': 'vegetable'},
|
|
||||||
{'something': {'or': 'other'},
|
|
||||||
'vegetable': {'some_variable': 'poolf',
|
|
||||||
'mail_port': '2020',
|
|
||||||
'CELERYD_ETA_SCHEDULER_PRECISION': '3.1',
|
|
||||||
'celery_result_persistent': 'false',
|
|
||||||
'celery_imports': 'baz.bar.foo import.is.a.this'}},
|
|
||||||
'mediagoblin.tests.fake_celery_module', set_environ=False)
|
'mediagoblin.tests.fake_celery_module', set_environ=False)
|
||||||
|
|
||||||
from mediagoblin.tests import fake_celery_module
|
from mediagoblin.tests import fake_celery_module
|
||||||
|
Loading…
x
Reference in New Issue
Block a user