Preparing celery unit tests for new setup.
authorChristopher Allan Webber <cwebber@dustycloud.org>
Sun, 19 Jun 2011 01:15:46 +0000 (20:15 -0500)
committerChristopher Allan Webber <cwebber@dustycloud.org>
Sun, 19 Jun 2011 01:15:46 +0000 (20:15 -0500)
Instead of the previous passing in of dictionaries, we're actually
checking some example config files.

mediagoblin/config_spec.ini
mediagoblin/tests/fake_celery_conf.ini [new file with mode: 0644]
mediagoblin/tests/fake_celery_conf_mgdb.ini [new file with mode: 0644]
mediagoblin/tests/test_celery_setup.py

index 52e3fdfd1432ce5b248e471b634326e354626aeb..aadf5c2106a4fc64d124bfe45200860ade49ce8a 100644 (file)
@@ -1,4 +1,9 @@
 [mediagoblin]
+# database stuff
+db_host = string()
+db_name = string()
+db_port = integer()
+
 # 
 queuestore_base_dir = string(default="%(here)s/user_dev/media/queue")
 publicstore_base_dir = string(default="%(here)s/user_dev/media/public")
diff --git a/mediagoblin/tests/fake_celery_conf.ini b/mediagoblin/tests/fake_celery_conf.ini
new file mode 100644 (file)
index 0000000..3e52ac3
--- /dev/null
@@ -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
diff --git a/mediagoblin/tests/fake_celery_conf_mgdb.ini b/mediagoblin/tests/fake_celery_conf_mgdb.ini
new file mode 100644 (file)
index 0000000..52671c1
--- /dev/null
@@ -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
index 558eb458abf38b4dca119933c4abd529fa865065..8bf97ae4b68d18099e6a32121e98695fad351476 100644 (file)
 import pkg_resources
 
 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():
@@ -27,14 +34,12 @@ def test_setup_celery_from_config():
         for var in vars_to_wipe:
             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(
-        {},
-        {'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'}},
+        app_config, global_config,
         'mediagoblin.tests.fake_celery_module', set_environ=False)
 
     from mediagoblin.tests import fake_celery_module
@@ -53,17 +58,12 @@ def test_setup_celery_from_config():
 
     _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(
-        {'db_host': 'mongodb.example.org',
-         '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'}},
+        app_config, global_config,
         'mediagoblin.tests.fake_celery_module', set_environ=False)
     
     from mediagoblin.tests import fake_celery_module