Add test for gnuviechadmin.celery
This commit adds a refactoring for gnuviechadmin.celery to make the installed apps detection testable. The test is added in gnuviechadmin.tests.test_celery. Debug code in gnuviechadmin.urls is no excluded from coverage reporting.
This commit is contained in:
parent
7bcb0d3100
commit
be0531ec30
3 changed files with 15 additions and 2 deletions
|
@ -12,5 +12,8 @@ os.environ.setdefault('DJANGO_SETTINGS_MODULE',
|
||||||
|
|
||||||
app = Celery('gnuviechadmin')
|
app = Celery('gnuviechadmin')
|
||||||
|
|
||||||
|
def get_installed_apps():
|
||||||
|
return settings.INSTALLED_APPS
|
||||||
|
|
||||||
app.config_from_object('django.conf:settings')
|
app.config_from_object('django.conf:settings')
|
||||||
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
|
app.autodiscover_tasks(get_installed_apps)
|
||||||
|
|
10
gnuviechadmin/gnuviechadmin/tests/test_celery.py
Normal file
10
gnuviechadmin/gnuviechadmin/tests/test_celery.py
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
from unittest import TestCase
|
||||||
|
|
||||||
|
from gnuviechadmin.celery import get_installed_apps
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
|
|
||||||
|
class GetInstalledAppsTest(TestCase):
|
||||||
|
|
||||||
|
def test_get_installed_apps(self):
|
||||||
|
self.assertEqual(get_installed_apps(), settings.INSTALLED_APPS)
|
|
@ -27,7 +27,7 @@ urlpatterns += patterns(
|
||||||
# Uncomment the next line to serve media files in dev.
|
# Uncomment the next line to serve media files in dev.
|
||||||
# urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
# urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||||
|
|
||||||
if settings.DEBUG:
|
if settings.DEBUG: # pragma: no cover
|
||||||
import debug_toolbar
|
import debug_toolbar
|
||||||
urlpatterns += patterns('',
|
urlpatterns += patterns('',
|
||||||
url(r'^__debug__/', include(debug_toolbar.urls)),
|
url(r'^__debug__/', include(debug_toolbar.urls)),
|
||||||
|
|
Loading…
Reference in a new issue