Move db/util.py -> db/mongo/util.py
[mediagoblin.git] / mediagoblin / tests / test_celery_setup.py
index da18b0ef58c71507a143510844518db3fc0bb86c..19a9b899de917d0a32ac3e46194aeb21f60d42a7 100644 (file)
@@ -1,5 +1,5 @@
 # GNU MediaGoblin -- federated, autonomous media hosting
-# Copyright (C) 2011 Free Software Foundation, Inc
+# Copyright (C) 2011 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
 
 import pkg_resources
 
-from mediagoblin import celery_setup
+from mediagoblin.init import celery as celery_setup
+from mediagoblin.init.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
@@ -45,7 +50,7 @@ def test_setup_celery_from_config():
     assert isinstance(fake_celery_module.CELERYD_ETA_SCHEDULER_PRECISION, float)
     assert fake_celery_module.CELERY_RESULT_PERSISTENT is True
     assert fake_celery_module.CELERY_IMPORTS == [
-        'foo.bar.baz', 'this.is.an.import']
+        'foo.bar.baz', 'this.is.an.import', 'mediagoblin.processing']
     assert fake_celery_module.CELERY_MONGODB_BACKEND_SETTINGS == {
         'database': 'mediagoblin'}
     assert fake_celery_module.CELERY_RESULT_BACKEND == 'mongodb'
@@ -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
@@ -74,7 +74,7 @@ def test_setup_celery_from_config():
     assert isinstance(fake_celery_module.CELERYD_ETA_SCHEDULER_PRECISION, float)
     assert fake_celery_module.CELERY_RESULT_PERSISTENT is False
     assert fake_celery_module.CELERY_IMPORTS == [
-        'baz.bar.foo', 'import.is.a.this']
+        'baz.bar.foo', 'import.is.a.this', 'mediagoblin.processing']
     assert fake_celery_module.CELERY_MONGODB_BACKEND_SETTINGS == {
         'database': 'captain_lollerskates',
         'host': 'mongodb.example.org',