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:
Jan Dittberner 2015-11-22 14:31:04 +01:00
parent 7bcb0d3100
commit be0531ec30
3 changed files with 15 additions and 2 deletions

View File

@ -12,5 +12,8 @@ os.environ.setdefault('DJANGO_SETTINGS_MODULE',
app = Celery('gnuviechadmin')
def get_installed_apps():
return settings.INSTALLED_APPS
app.config_from_object('django.conf:settings')
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
app.autodiscover_tasks(get_installed_apps)

View 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)

View File

@ -27,7 +27,7 @@ urlpatterns += patterns(
# Uncomment the next line to serve media files in dev.
# urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
if settings.DEBUG:
if settings.DEBUG: # pragma: no cover
import debug_toolbar
urlpatterns += patterns('',
url(r'^__debug__/', include(debug_toolbar.urls)),