-
-
Notifications
You must be signed in to change notification settings - Fork 15
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
Showing
8 changed files
with
348 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
.. _default-tasks: | ||
|
||
================ | ||
Built-in Tasks | ||
================ | ||
|
||
:Release: |version| | ||
:Date: |today| | ||
|
||
The plugin provides a list of built-in celery tasks that can be used out of the box. This page will | ||
list all the available tasks. | ||
|
||
.. tip:: | ||
|
||
The tasks injected into the workers that use the default volume with: | ||
|
||
.. code-block:: python | ||
volumes={"{default_worker_volume.name}": defaults.DEFAULT_WORKER_VOLUME}, | ||
.. contents:: | ||
:local: | ||
:depth: 1 | ||
|
||
add | ||
=== | ||
|
||
.. versionadded:: 1.0.0 | ||
|
||
.. literalinclude:: ../../src/pytest_celery/vendors/worker/tasks.py | ||
:language: python | ||
:caption: pytest_celery.vendors.worker.tasks | ||
:start-after: # ------------- add ------------- | ||
:end-before: # ------------- add_replaced ------------- | ||
|
||
add_replaced | ||
============ | ||
|
||
.. versionadded:: 1.0.0 | ||
|
||
.. literalinclude:: ../../src/pytest_celery/vendors/worker/tasks.py | ||
:language: python | ||
:caption: pytest_celery.vendors.worker.tasks | ||
:start-after: # ------------- add_replaced ------------- | ||
:end-before: # ------------- fail ------------- | ||
|
||
fail | ||
==== | ||
|
||
.. versionadded:: 1.0.0 | ||
|
||
.. literalinclude:: ../../src/pytest_celery/vendors/worker/tasks.py | ||
:language: python | ||
:caption: pytest_celery.vendors.worker.tasks | ||
:start-after: # ------------- fail ------------- | ||
:end-before: # ------------- identity ------------- | ||
|
||
identity | ||
======== | ||
|
||
.. versionadded:: 1.0.0 | ||
|
||
.. literalinclude:: ../../src/pytest_celery/vendors/worker/tasks.py | ||
:language: python | ||
:caption: pytest_celery.vendors.worker.tasks | ||
:start-after: # ------------- identity ------------- | ||
:end-before: # ------------- noop ------------- | ||
|
||
noop | ||
==== | ||
|
||
.. versionadded:: 1.0.0 | ||
|
||
.. literalinclude:: ../../src/pytest_celery/vendors/worker/tasks.py | ||
:language: python | ||
:caption: pytest_celery.vendors.worker.tasks | ||
:start-after: # ------------- noop ------------- | ||
:end-before: # ------------- ping ------------- | ||
|
||
ping | ||
==== | ||
|
||
.. versionadded:: 1.0.0 | ||
|
||
.. literalinclude:: ../../src/pytest_celery/vendors/worker/tasks.py | ||
:language: python | ||
:caption: pytest_celery.vendors.worker.tasks | ||
:start-after: # ------------- ping ------------- | ||
:end-before: # ------------- sleep ------------- | ||
|
||
sleep | ||
===== | ||
|
||
.. versionadded:: 1.0.0 | ||
|
||
.. literalinclude:: ../../src/pytest_celery/vendors/worker/tasks.py | ||
:language: python | ||
:caption: pytest_celery.vendors.worker.tasks | ||
:start-after: # ------------- sleep ------------- | ||
:end-before: # ------------- xsum ------------- | ||
|
||
xsum | ||
==== | ||
|
||
.. versionadded:: 1.0.0 | ||
|
||
.. literalinclude:: ../../src/pytest_celery/vendors/worker/tasks.py | ||
:language: python | ||
:caption: pytest_celery.vendors.worker.tasks | ||
:start-after: # ------------- xsum ------------- |
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import pytest | ||
|
||
from pytest_celery import RESULT_TIMEOUT | ||
from pytest_celery import CeleryTestSetup | ||
from pytest_celery import add | ||
from pytest_celery import add_replaced | ||
from pytest_celery import fail | ||
from pytest_celery import identity | ||
from pytest_celery import noop | ||
from pytest_celery import ping | ||
from pytest_celery import sleep | ||
from pytest_celery import xsum | ||
|
||
|
||
class test_default_tasks: | ||
def test_add(self, celery_setup: CeleryTestSetup): | ||
assert add.s(1, 2).apply_async(queue=celery_setup.worker.worker_queue).get(timeout=RESULT_TIMEOUT) == 3 | ||
|
||
def test_add_replaced(self, celery_setup: CeleryTestSetup): | ||
queue = celery_setup.worker.worker_queue | ||
add_replaced.s(1, 2, queue=queue).apply_async(queue=queue) | ||
celery_setup.worker.assert_log_exists("ignored") | ||
|
||
def test_fail(self, celery_setup: CeleryTestSetup): | ||
with pytest.raises(RuntimeError): | ||
fail.s().apply_async(queue=celery_setup.worker.worker_queue).get(timeout=RESULT_TIMEOUT) | ||
|
||
def test_identity(self, celery_setup: CeleryTestSetup): | ||
assert identity.s(1).apply_async(queue=celery_setup.worker.worker_queue).get(timeout=RESULT_TIMEOUT) == 1 | ||
|
||
def test_noop(self, celery_setup: CeleryTestSetup): | ||
assert noop.s().apply_async(queue=celery_setup.worker.worker_queue).get(timeout=RESULT_TIMEOUT) is None | ||
|
||
def test_ping(self, celery_setup: CeleryTestSetup): | ||
assert ping.s().apply_async(queue=celery_setup.worker.worker_queue).get(timeout=RESULT_TIMEOUT) == "pong" | ||
|
||
def test_sleep(self, celery_setup: CeleryTestSetup): | ||
assert sleep.s().apply_async(queue=celery_setup.worker.worker_queue).get(timeout=RESULT_TIMEOUT) is True | ||
|
||
def test_xsum(self, celery_setup: CeleryTestSetup): | ||
assert xsum.s([1, 2, 3]).apply_async(queue=celery_setup.worker.worker_queue).get(timeout=RESULT_TIMEOUT) == 6 | ||
|
||
def test_xsum_nested_list(self, celery_setup: CeleryTestSetup): | ||
assert ( | ||
xsum.s([[1, 2], [3, 4], [5, 6]]) | ||
.apply_async(queue=celery_setup.worker.worker_queue) | ||
.get(timeout=RESULT_TIMEOUT) | ||
== 21 | ||
) |
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
Oops, something went wrong.