Skip to content

Commit

Permalink
Migrate Telegram example DAGs to new design #22468 (#24126)
Browse files Browse the repository at this point in the history
  • Loading branch information
chethanuk committed Jun 3, 2022
1 parent 32a158a commit 2f0ee38
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 29 deletions.
17 changes: 0 additions & 17 deletions airflow/providers/telegram/example_dags/__init__.py

This file was deleted.

2 changes: 1 addition & 1 deletion docs/apache-airflow-providers-telegram/index.rst
Expand Up @@ -38,7 +38,7 @@ Content
:maxdepth: 1
:caption: Resources

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

Expand Down
2 changes: 1 addition & 1 deletion docs/apache-airflow-providers-telegram/operators.rst
Expand Up @@ -48,7 +48,7 @@ the connection metadata is structured as follows:

An example usage of the TelegramOperator is as follows:

.. exampleinclude:: /../../airflow/providers/telegram/example_dags/example_telegram.py
.. exampleinclude:: /../../tests/system/providers/telegram/example_telegram.py
:language: python
:start-after: [START howto_operator_telegram]
:end-before: [END howto_operator_telegram]
Expand Down
Expand Up @@ -19,21 +19,32 @@
Example use of Telegram operator.
"""

import os
from datetime import datetime

from airflow import DAG
from airflow.providers.telegram.operators.telegram import TelegramOperator

dag = DAG('example_telegram', start_date=datetime(2021, 1, 1), tags=['example'])
ENV_ID = os.environ.get("SYSTEM_TESTS_ENV_ID")
DAG_ID = "example_telegram"
CONN_ID = "telegram_conn_id"
CHAT_ID = "-3222103937"

# [START howto_operator_telegram]
with DAG(DAG_ID, start_date=datetime(2021, 1, 1), tags=['example']) as dag:

send_message_telegram_task = TelegramOperator(
task_id='send_message_telegram',
telegram_conn_id='telegram_conn_id',
chat_id='-3222103937',
text='Hello from Airflow!',
dag=dag,
)
# [START howto_operator_telegram]

# [END howto_operator_telegram]
send_message_telegram_task = TelegramOperator(
task_id='send_message_telegram',
telegram_conn_id=CONN_ID,
chat_id=CHAT_ID,
text='Hello from Airflow!',
dag=dag,
)

# [END howto_operator_telegram]

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)

0 comments on commit 2f0ee38

Please sign in to comment.