-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from taskbadger/sk/celery-upgrade
fix celery serialization bug
- Loading branch information
Showing
8 changed files
with
776 additions
and
385 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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 |
---|---|---|
|
@@ -13,7 +13,7 @@ | |
import celery | ||
import pytest | ||
|
||
from taskbadger import StatusEnum | ||
from taskbadger import Action, EmailIntegration, StatusEnum | ||
from taskbadger.celery import Task | ||
from taskbadger.mug import Badger | ||
from tests.utils import task_for_test | ||
|
@@ -75,6 +75,32 @@ def add_with_task_args(self, a, b): | |
create.assert_called_once_with("new_name", value_max=10, data={"foo": "bar"}, status=StatusEnum.PENDING) | ||
|
||
|
||
def test_celery_task_with_kwargs(celery_session_app, celery_session_worker, bind_settings): | ||
@celery_session_app.task(bind=True, base=Task) | ||
def add_with_task_args(self, a, b): | ||
assert self.taskbadger_task is not None | ||
return a + b | ||
|
||
celery_session_worker.reload() | ||
|
||
with mock.patch("taskbadger.celery.create_task_safe") as create, mock.patch( | ||
"taskbadger.celery.update_task_safe" | ||
) as update, mock.patch("taskbadger.celery.get_task") as get_task: | ||
create.return_value = task_for_test() | ||
|
||
actions = [Action("stale", integration=EmailIntegration(to="[email protected]"))] | ||
result = add_with_task_args.delay( | ||
2, | ||
2, | ||
taskbadger_name="new_name", | ||
taskbadger_value_max=10, | ||
taskbadger_kwargs={"actions": actions}, | ||
) | ||
assert result.get(timeout=10, propagate=True) == 4 | ||
|
||
create.assert_called_once_with("new_name", value_max=10, actions=actions, status=StatusEnum.PENDING) | ||
|
||
|
||
def test_celery_task_with_args_in_decorator(celery_session_app, celery_session_worker, bind_settings): | ||
@celery_session_app.task(bind=True, base=Task, taskbadger_value_max=10, taskbadger_kwargs={"monitor_id": "123"}) | ||
def add_with_task_args_in_decorator(self, a, b): | ||
|
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