Skip to content
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
14 changes: 6 additions & 8 deletions providers/telegram/tests/unit/telegram/hooks/test_telegram.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@
import airflow
from airflow.models import Connection
from airflow.providers.telegram.hooks.telegram import TelegramHook
from airflow.utils import db

pytestmark = pytest.mark.db_test


TELEGRAM_TOKEN = "dummy token"

Expand All @@ -44,21 +40,22 @@ def telegram_error_side_effect(*args, **kwargs):


class TestTelegramHook:
def setup_method(self):
db.merge_conn(
@pytest.fixture(autouse=True)
def setup_connections(self, create_connection_without_db):
create_connection_without_db(
Connection(
conn_id="telegram-webhook-without-token",
conn_type="http",
)
)
db.merge_conn(
create_connection_without_db(
Connection(
conn_id="telegram_default",
conn_type="http",
password=TELEGRAM_TOKEN,
)
)
db.merge_conn(
create_connection_without_db(
Connection(
conn_id="telegram-webhook-with-chat_id",
conn_type="http",
Expand All @@ -73,6 +70,7 @@ def test_should_use_default_connection(self):
assert hook.token == TELEGRAM_TOKEN
assert not hook.chat_id

@pytest.mark.db_test
def test_should_raise_exception_if_conn_id_doesnt_exist(self):
with pytest.raises(airflow.exceptions.AirflowNotFoundException) as ctx:
TelegramHook(telegram_conn_id="telegram-webhook-non-existent")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
from airflow.models import Connection
from airflow.providers.telegram.operators.telegram import TelegramOperator

pytestmark = pytest.mark.db_test

TELEGRAM_TOKEN = "xxx:xxx"


Expand Down