Sfoglia il codice sorgente

100% coverage for celery.backends.database

Ask Solem 14 anni fa
parent
commit
4eff2a4fd5
1 ha cambiato i file con 10 aggiunte e 0 eliminazioni
  1. 10 0
      celery/tests/test_backends/test_database.py

+ 10 - 0
celery/tests/test_backends/test_database.py

@@ -11,6 +11,8 @@ from celery.db.models import Task, TaskSet
 from celery.result import AsyncResult
 from celery.utils import gen_unique_id
 
+from celery.tests.utils import execute_context, mask_modules
+
 
 class SomeClass(object):
 
@@ -20,6 +22,14 @@ class SomeClass(object):
 
 class test_DatabaseBackend(unittest.TestCase):
 
+    def test_missing_SQLAlchemy_raises_ImproperlyConfigured(self):
+
+        def with_SQLAlchemy_masked(_val):
+            from celery.backends.database import _sqlalchemy_installed
+            self.assertRaises(ImproperlyConfigured, _sqlalchemy_installed)
+
+        execute_context(mask_modules("sqlalchemy"), with_SQLAlchemy_masked)
+
     def test_missing_dburi_raises_ImproperlyConfigured(self):
         conf = app_or_default().conf
         prev, conf.CELERY_RESULT_DBURI = conf.CELERY_RESULT_DBURI, None