Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate DingTalk example DAGs to new design #22443 #24133

Merged
merged 2 commits into from
Jun 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions airflow/providers/dingding/example_dags/__init__.py

This file was deleted.

2 changes: 1 addition & 1 deletion docs/apache-airflow-providers-dingding/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Content
:maxdepth: 1
:caption: Resources

Example DAGs <https://github.com/apache/airflow/tree/main/airflow/providers/dingding/example_dags>
Example DAGs <https://github.com/apache/airflow/tree/main/tests/system/providers/dingding>
PyPI Repository <https://pypi.org/project/apache-airflow-providers-dingding/>
Installing from sources <installing-providers-from-sources>

Expand Down
8 changes: 4 additions & 4 deletions docs/apache-airflow-providers-dingding/operators.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Basic Usage
Use the :class:`~airflow.providers.dingding.operators.dingding.DingdingOperator`
to send Dingding message:

.. exampleinclude:: /../../airflow/providers/dingding/example_dags/example_dingding.py
.. exampleinclude:: /../../tests/system/providers/dingding/example_dingding.py
:language: python
:dedent: 4
:start-after: [START howto_operator_dingding]
Expand All @@ -50,7 +50,7 @@ Remind users in message
Use parameters ``at_mobiles`` and ``at_all`` to remind specific users when you send message,
``at_mobiles`` will be ignored When ``at_all`` is set to ``True``:

.. exampleinclude:: /../../airflow/providers/dingding/example_dags/example_dingding.py
.. exampleinclude:: /../../tests/system/providers/dingding/example_dingding.py
:language: python
:dedent: 4
:start-after: [START howto_operator_dingding_remind_users]
Expand All @@ -63,7 +63,7 @@ Send rich text message
The Dingding operator can send rich text messages including link, markdown, actionCard and feedCard.
A rich text message can not remind specific users except by using markdown type message:

.. exampleinclude:: /../../airflow/providers/dingding/example_dags/example_dingding.py
.. exampleinclude:: /../../tests/system/providers/dingding/example_dingding.py
:language: python
:dedent: 4
:start-after: [START howto_operator_dingding_rich_text]
Expand All @@ -77,7 +77,7 @@ Dingding operator could handle task callback by writing a function wrapper dingd
and then pass the function to ``sla_miss_callback``, ``on_success_callback``, ``on_failure_callback``,
or ``on_retry_callback``. Here we use ``on_failure_callback`` as an example:

.. exampleinclude:: /../../airflow/providers/dingding/example_dags/example_dingding.py
.. exampleinclude:: /../../tests/system/providers/dingding/example_dingding.py
:language: python
:start-after: [START howto_operator_dingding_failure_callback]
:end-before: [END howto_operator_dingding_failure_callback]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@
"""
This is an example dag for using the DingdingOperator.
"""
import os
from datetime import datetime, timedelta

from airflow import DAG
from airflow.providers.dingding.operators.dingding import DingdingOperator

ENV_ID = os.environ.get("SYSTEM_TESTS_ENV_ID")
DAG_ID = "example_dingding_operator"


# [START howto_operator_dingding_failure_callback]
def failure_callback(context):
Expand All @@ -48,7 +52,7 @@ def failure_callback(context):
# [END howto_operator_dingding_failure_callback]

with DAG(
dag_id='example_dingding_operator',
dag_id=DAG_ID,
default_args={'retries': 3, 'on_failure_callback': failure_callback},
schedule_interval='@once',
dagrun_timeout=timedelta(minutes=60),
Expand Down Expand Up @@ -201,3 +205,14 @@ def failure_callback(context):
>> feed_card_msg
>> msg_failure_callback
)

from tests.system.utils.watcher import watcher

# This test needs watcher in order to properly mark success/failure
# when "tearDown" task with trigger rule is part of the DAG
list(dag.tasks) >> watcher()

from tests.system.utils import get_test_run # noqa: E402

# Needed to run the example DAG with pytest (see: tests/system/README.md#run_via_pytest)
test_run = get_test_run(dag)