You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by go...@apache.org on 2025/08/19 20:04:40 UTC
(airflow) branch main updated: Make AWS notifier tests db independent (#54668)
This is an automated email from the ASF dual-hosted git repository.
gopidesu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new e1718cd3da2 Make AWS notifier tests db independent (#54668)
e1718cd3da2 is described below
commit e1718cd3da201a871f896cca1c7121af9a840f7b
Author: GPK <go...@gmail.com>
AuthorDate: Tue Aug 19 21:04:33 2025 +0100
Make AWS notifier tests db independent (#54668)
---
.../unit/amazon/aws/notifications/test_chime.py | 24 ++++++----------------
.../unit/amazon/aws/notifications/test_sns.py | 9 ++------
.../unit/amazon/aws/notifications/test_sqs.py | 13 ++++--------
3 files changed, 12 insertions(+), 34 deletions(-)
diff --git a/providers/amazon/tests/unit/amazon/aws/notifications/test_chime.py b/providers/amazon/tests/unit/amazon/aws/notifications/test_chime.py
index 9e325ae1e85..0923a61e543 100644
--- a/providers/amazon/tests/unit/amazon/aws/notifications/test_chime.py
+++ b/providers/amazon/tests/unit/amazon/aws/notifications/test_chime.py
@@ -24,9 +24,6 @@ import pytest
from airflow.models import Connection
from airflow.providers.amazon.aws.hooks.chime import ChimeWebhookHook
from airflow.providers.amazon.aws.notifications.chime import ChimeNotifier, send_chime_notification
-from airflow.providers.standard.operators.empty import EmptyOperator
-
-pytestmark = pytest.mark.db_test
class TestChimeNotifier:
@@ -44,34 +41,25 @@ class TestChimeNotifier:
)
@mock.patch.object(ChimeWebhookHook, "send_message")
- def test_chime_notifier(self, mock_chime_hook, dag_maker):
- with dag_maker("test_chime_notifier") as dag:
- EmptyOperator(task_id="task1")
-
+ def test_chime_notifier(self, mock_chime_hook, create_dag_without_db):
notifier = send_chime_notification(
chime_conn_id="default-chime-webhook", message="Chime Test Message"
)
- notifier({"dag": dag})
+ notifier({"dag": create_dag_without_db("test_chime_notifier")})
mock_chime_hook.assert_called_once_with(message="Chime Test Message")
@mock.patch.object(ChimeWebhookHook, "send_message")
- def test_chime_notifier_with_notifier_class(self, mock_chime_hook, dag_maker):
- with dag_maker("test_chime_notifier") as dag:
- EmptyOperator(task_id="task1")
-
+ def test_chime_notifier_with_notifier_class(self, mock_chime_hook, create_dag_without_db):
notifier = ChimeNotifier(
chime_conn_id="default-chime-webhook", message="Test Chime Message for Class"
)
- notifier({"dag": dag})
+ notifier({"dag": create_dag_without_db("test_chime_notifier")})
mock_chime_hook.assert_called_once_with(message="Test Chime Message for Class")
@mock.patch.object(ChimeWebhookHook, "send_message")
- def test_chime_notifier_templated(self, mock_chime_hook, dag_maker):
- with dag_maker("test_chime_notifier") as dag:
- EmptyOperator(task_id="task1")
-
+ def test_chime_notifier_templated(self, mock_chime_hook, create_dag_without_db):
notifier = send_chime_notification(
chime_conn_id="default-chime-webhook", message="Test Chime Message. Dag is {{ dag.dag_id }}."
)
- notifier({"dag": dag})
+ notifier({"dag": create_dag_without_db("test_chime_notifier")})
mock_chime_hook.assert_called_once_with(message="Test Chime Message. Dag is test_chime_notifier.")
diff --git a/providers/amazon/tests/unit/amazon/aws/notifications/test_sns.py b/providers/amazon/tests/unit/amazon/aws/notifications/test_sns.py
index 7cf88de3de1..87f1bfb94cc 100644
--- a/providers/amazon/tests/unit/amazon/aws/notifications/test_sns.py
+++ b/providers/amazon/tests/unit/amazon/aws/notifications/test_sns.py
@@ -21,7 +21,6 @@ from unittest import mock
import pytest
from airflow.providers.amazon.aws.notifications.sns import SnsNotifier, send_sns_notification
-from airflow.providers.standard.operators.empty import EmptyOperator
from airflow.utils.types import NOTSET
PARAM_DEFAULT_VALUE = pytest.param(NOTSET, id="default-value")
@@ -60,11 +59,7 @@ class TestSnsNotifier:
notifier.notify({})
mock_hook.return_value.publish_to_target.assert_called_once_with(**publish_kwargs)
- @pytest.mark.db_test
- def test_sns_notifier_templated(self, dag_maker):
- with dag_maker("test_sns_notifier_templated") as dag:
- EmptyOperator(task_id="task1")
-
+ def test_sns_notifier_templated(self, create_dag_without_db):
notifier = SnsNotifier(
aws_conn_id="{{ dag.dag_id }}",
target_arn="arn:aws:sns:{{ var_region }}:{{ var_account }}:{{ var_topic }}",
@@ -76,7 +71,7 @@ class TestSnsNotifier:
with mock.patch("airflow.providers.amazon.aws.notifications.sns.SnsHook") as m:
notifier(
{
- "dag": dag,
+ "dag": create_dag_without_db("test_sns_notifier_templated"),
"var_username": "Robot",
"var_region": "us-west-1",
"var_account": "000000000000",
diff --git a/providers/amazon/tests/unit/amazon/aws/notifications/test_sqs.py b/providers/amazon/tests/unit/amazon/aws/notifications/test_sqs.py
index a4d5aab2db3..cb934e9ef7a 100644
--- a/providers/amazon/tests/unit/amazon/aws/notifications/test_sqs.py
+++ b/providers/amazon/tests/unit/amazon/aws/notifications/test_sqs.py
@@ -21,7 +21,6 @@ from unittest import mock
import pytest
from airflow.providers.amazon.aws.notifications.sqs import SqsNotifier, send_sqs_notification
-from airflow.providers.standard.operators.empty import EmptyOperator
from airflow.utils.types import NOTSET
PARAM_DEFAULT_VALUE = pytest.param(NOTSET, id="default-value")
@@ -61,11 +60,7 @@ class TestSqsNotifier:
notifier.notify({})
mock_hook.return_value.send_message.assert_called_once_with(**send_message_kwargs)
- @pytest.mark.db_test
- def test_sqs_notifier_templated(self, dag_maker):
- with dag_maker("test_sns_notifier_templated") as dag:
- EmptyOperator(task_id="task1")
-
+ def test_sqs_notifier_templated(self, create_dag_without_db):
notifier = SqsNotifier(
aws_conn_id="{{ dag.dag_id }}",
queue_url="https://sqs.{{ var_region }}.amazonaws.com/{{ var_account }}/{{ var_queue }}",
@@ -77,7 +72,7 @@ class TestSqsNotifier:
with mock.patch("airflow.providers.amazon.aws.notifications.sqs.SqsHook") as m:
notifier(
{
- "dag": dag,
+ "dag": create_dag_without_db("test_sqs_notifier_templated"),
"var_username": "truman",
"var_region": "ca-central-1",
"var_account": "123321123321",
@@ -86,12 +81,12 @@ class TestSqsNotifier:
}
)
# Hook initialisation
- m.assert_called_once_with(aws_conn_id="test_sns_notifier_templated", region_name="ca-central-1")
+ m.assert_called_once_with(aws_conn_id="test_sqs_notifier_templated", region_name="ca-central-1")
# Send message
m.return_value.send_message.assert_called_once_with(
queue_url="https://sqs.ca-central-1.amazonaws.com/123321123321/AwesomeQueue",
message_body="The Truman Show",
message_group_id="spam",
- message_attributes={"bar": "test_sns_notifier_templated"},
+ message_attributes={"bar": "test_sqs_notifier_templated"},
delay_seconds=0,
)