-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CeleryApp allows overriding the task class. (#78)
* CeleryApp allows overriding the task class. Fixes #76 * Don't set test app as current
- Loading branch information
1 parent
9f76a5c
commit 66ad4aa
Showing
2 changed files
with
35 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from tenant_schemas_celery.app import CeleryApp | ||
from tenant_schemas_celery.task import TenantTask | ||
|
||
|
||
class DummyTask(TenantTask): | ||
... | ||
|
||
|
||
def test_celery_app_should_allow_overriding_task_cls_as_object() -> None: | ||
class App(CeleryApp): | ||
task_cls = DummyTask | ||
|
||
app = App(set_as_current=False) | ||
|
||
@app.task() | ||
def some_task() -> None: | ||
... | ||
|
||
assert isinstance(some_task, DummyTask) | ||
|
||
|
||
def test_celery_app_should_allow_overriding_task_cls_as_string() -> None: | ||
class App(CeleryApp): | ||
task_cls = f"{DummyTask.__module__}:{DummyTask.__name__}" | ||
|
||
app = App(set_as_current=False) | ||
|
||
@app.task() | ||
def some_task() -> None: | ||
... | ||
|
||
assert isinstance(some_task, DummyTask) |