forked from ask/flask-celery
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ask Solem
committed
Sep 8, 2010
1 parent
09a67e2
commit 52f8a8c
Showing
4 changed files
with
70 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import unittest2 as unittest | ||
|
||
import flask | ||
|
||
from flaskext import celery | ||
|
||
|
||
class test_Celery(unittest.TestCase): | ||
|
||
def setUp(self): | ||
self.app = flask.Flask(__name__) | ||
self.c = celery.Celery(self.app) | ||
|
||
def test_loader_is_configured(self): | ||
from celery.loaders import current_loader, load_settings | ||
loader = current_loader() | ||
self.assertIsInstance(loader, celery.FlaskLoader) | ||
settings = load_settings() | ||
self.assertTrue(loader.configured) | ||
|
||
def test_task_honors_app_settings(self): | ||
app = flask.Flask(__name__) | ||
app.config["CELERY_IGNORE_RESULT"] = True | ||
app.config["CELERY_TASK_SERIALIZER"] = "msgpack" | ||
c = celery.Celery(app) | ||
|
||
@c.task(foo=1) | ||
def add_task_args(x, y): | ||
return x + y | ||
|
||
@c.task | ||
def add_task_noargs(x, y): | ||
return x + y | ||
|
||
for task in add_task_args, add_task_noargs: | ||
self.assertTrue(any("BaseFlaskTask" in repr(cls) | ||
for cls in task.__class__.mro())) | ||
self.assertEqual(task(2, 2), 4) | ||
self.assertEqual(task.serializer, "msgpack") | ||
self.assertTrue(task.ignore_result) |