diff --git a/airflow/providers/telegram/example_dags/__init__.py b/airflow/providers/telegram/example_dags/__init__.py deleted file mode 100644 index 217e5db960782..0000000000000 --- a/airflow/providers/telegram/example_dags/__init__.py +++ /dev/null @@ -1,17 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. diff --git a/docs/apache-airflow-providers-telegram/operators.rst b/docs/apache-airflow-providers-telegram/operators.rst index 7937a662039a2..e317264b3adc9 100644 --- a/docs/apache-airflow-providers-telegram/operators.rst +++ b/docs/apache-airflow-providers-telegram/operators.rst @@ -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] diff --git a/airflow/providers/telegram/example_dags/example_telegram.py b/tests/system/providers/telegram/example_telegram.py similarity index 75% rename from airflow/providers/telegram/example_dags/example_telegram.py rename to tests/system/providers/telegram/example_telegram.py index 76e71800ecb2d..4ee17f48b8649 100644 --- a/airflow/providers/telegram/example_dags/example_telegram.py +++ b/tests/system/providers/telegram/example_telegram.py @@ -18,22 +18,31 @@ """ 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' + +dag = DAG(DAG_ID, start_date=datetime(2021, 1, 1), tags=['example']) # [START howto_operator_telegram] send_message_telegram_task = TelegramOperator( task_id='send_message_telegram', - telegram_conn_id='telegram_conn_id', + telegram_conn_id=CONN_ID, chat_id='-3222103937', 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)