SciPost Code Repository
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SciPost
Manage
Activity
Members
Labels
Plan
Issues
118
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SciPost
SciPost
Commits
b448557f
Commit
b448557f
authored
6 years ago
by
Jorran de Wit
Browse files
Options
Downloads
Patches
Plain Diff
Add tests for celery
parent
cf92f8cb
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
SciPost_v1/celery.py
+22
-0
22 additions, 0 deletions
SciPost_v1/celery.py
SciPost_v1/settings/base.py
+8
-0
8 additions, 0 deletions
SciPost_v1/settings/base.py
scipost/tasks.py
+20
-0
20 additions, 0 deletions
scipost/tasks.py
with
50 additions
and
0 deletions
SciPost_v1/celery.py
0 → 100644
+
22
−
0
View file @
b448557f
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
))
This diff is collapsed.
Click to expand it.
SciPost_v1/settings/base.py
+
8
−
0
View file @
b448557f
...
@@ -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
'
,
)
This diff is collapsed.
Click to expand it.
scipost/tasks.py
0 → 100644
+
20
−
0
View file @
b448557f
__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
,
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment