SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit b448557f authored by Jorran de Wit's avatar Jorran de Wit
Browse files

Add tests for celery

parent cf92f8cb
No related branches found
No related tags found
No related merge requests found
from __future__ import absolute_import, unicode_literals
import os
from celery import Celery
# set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'SciPost_v1.settings')
app = Celery('SciPost_v1')
# Using a string here means the worker doesn't have to serialize
# the configuration object to child processes.
# - namespace='CELERY' means all celery-related configuration keys
# should have a `CELERY_` prefix.
app.config_from_object('django.conf:settings', namespace='CELERY')
# Load task modules from all registered Django app configs.
app.autodiscover_tasks()
@app.task(bind=True)
def debug_task(self):
print('Request: {0!r}'.format(self.request))
...@@ -88,6 +88,8 @@ INSTALLED_APPS = ( ...@@ -88,6 +88,8 @@ INSTALLED_APPS = (
'colleges', 'colleges',
'commentaries', 'commentaries',
'comments', 'comments',
'django_celery_results',
'django_celery_beat',
'finances', 'finances',
'guides', 'guides',
'invitations', 'invitations',
...@@ -358,3 +360,9 @@ LOGGING = { ...@@ -358,3 +360,9 @@ LOGGING = {
}, },
}, },
} }
# Celery scheduled tasks
CELERY_RESULT_BACKEND = 'django-db'
CELERY_BROKER_URL = 'amqp://localhost'
CELERY_IMPORTS = ('submissions.tasks', )
__copyright__ = "Copyright 2016-2018, Stichting SciPost (SciPost Foundation)"
__license__ = "AGPL v3"
from django.core.mail import send_mail
from SciPost_v1.celery import app
@app.task(bind=True)
def test_celery_using_mail(self):
"""Just testing the production server here."""
send_mail(
'Test subject',
'Received this mail?',
'noreply@scipost.org',
['jorrandewit@scipost.org'],
fail_silently=False,
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment