You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by po...@apache.org on 2025/06/24 10:17:41 UTC
(airflow) branch main updated: Remove pytestmark from Pagerduty test files (#52146)
This is an automated email from the ASF dual-hosted git repository.
potiuk 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 ad19251f74b Remove pytestmark from Pagerduty test files (#52146)
ad19251f74b is described below
commit ad19251f74b63447202c74a1e9849d9eb8b25fc8
Author: Yeonguk Choo <ch...@gmail.com>
AuthorDate: Tue Jun 24 19:17:35 2025 +0900
Remove pytestmark from Pagerduty test files (#52146)
* Remove pytestmark from Pagerduty test files
* Add PagerDuty provider to pre-commit
* fix: airflow.sdk error
---
.pre-commit-config.yaml | 1 +
.../tests/unit/pagerduty/hooks/test_pagerduty.py | 3 ---
.../unit/pagerduty/hooks/test_pagerduty_events.py | 2 --
.../unit/pagerduty/notifications/test_pagerduty.py | 22 +++++++---------------
4 files changed, 8 insertions(+), 20 deletions(-)
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 73265015836..5b6f496c35b 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -623,6 +623,7 @@ repos:
^providers/openai/.*\.py$|
^providers/openfaas/.*\.py$|
^providers/oracle/.*\.py$|
+ ^providers/pagerduty/.*\.py$|
^providers/pgvector/.*\.py$|
^providers/pinecone/.*\.py$|
^providers/postgres/.*\.py$|
diff --git a/providers/pagerduty/tests/unit/pagerduty/hooks/test_pagerduty.py b/providers/pagerduty/tests/unit/pagerduty/hooks/test_pagerduty.py
index e970e3a06b8..e7ca5451810 100644
--- a/providers/pagerduty/tests/unit/pagerduty/hooks/test_pagerduty.py
+++ b/providers/pagerduty/tests/unit/pagerduty/hooks/test_pagerduty.py
@@ -22,9 +22,6 @@ import pytest
from airflow.models import Connection
from airflow.providers.pagerduty.hooks.pagerduty import PagerdutyHook
-pytestmark = pytest.mark.db_test
-
-
DEFAULT_CONN_ID = "pagerduty_default"
diff --git a/providers/pagerduty/tests/unit/pagerduty/hooks/test_pagerduty_events.py b/providers/pagerduty/tests/unit/pagerduty/hooks/test_pagerduty_events.py
index 682194b51df..8d1136900cc 100644
--- a/providers/pagerduty/tests/unit/pagerduty/hooks/test_pagerduty_events.py
+++ b/providers/pagerduty/tests/unit/pagerduty/hooks/test_pagerduty_events.py
@@ -22,8 +22,6 @@ import pytest
from airflow.models import Connection
from airflow.providers.pagerduty.hooks.pagerduty_events import PagerdutyEventsHook
-pytestmark = pytest.mark.db_test
-
DEFAULT_CONN_ID = "pagerduty_events_default"
diff --git a/providers/pagerduty/tests/unit/pagerduty/notifications/test_pagerduty.py b/providers/pagerduty/tests/unit/pagerduty/notifications/test_pagerduty.py
index 69db5edcfb4..47394077a77 100644
--- a/providers/pagerduty/tests/unit/pagerduty/notifications/test_pagerduty.py
+++ b/providers/pagerduty/tests/unit/pagerduty/notifications/test_pagerduty.py
@@ -19,26 +19,20 @@ from __future__ import annotations
from unittest import mock
-import pytest
-
+from airflow import DAG
from airflow.providers.pagerduty.hooks.pagerduty_events import PagerdutyEventsHook
from airflow.providers.pagerduty.notifications.pagerduty import (
PagerdutyNotifier,
send_pagerduty_notification,
)
-from airflow.providers.standard.operators.empty import EmptyOperator
-
-pytestmark = pytest.mark.db_test
-
PAGERDUTY_API_DEFAULT_CONN_ID = PagerdutyEventsHook.default_conn_name
class TestPagerdutyNotifier:
@mock.patch("airflow.providers.pagerduty.notifications.pagerduty.PagerdutyEventsHook")
- def test_notifier(self, mock_pagerduty_event_hook, dag_maker):
- with dag_maker("test_notifier") as dag:
- EmptyOperator(task_id="task1")
+ def test_notifier(self, mock_pagerduty_event_hook):
+ dag = DAG("test_notifier")
notifier = send_pagerduty_notification(summary="DISK at 99%", severity="critical", action="trigger")
notifier({"dag": dag})
mock_pagerduty_event_hook.return_value.send_event.assert_called_once_with(
@@ -56,9 +50,8 @@ class TestPagerdutyNotifier:
)
@mock.patch("airflow.providers.pagerduty.notifications.pagerduty.PagerdutyEventsHook")
- def test_notifier_with_notifier_class(self, mock_pagerduty_event_hook, dag_maker):
- with dag_maker("test_notifier") as dag:
- EmptyOperator(task_id="task1")
+ def test_notifier_with_notifier_class(self, mock_pagerduty_event_hook):
+ dag = DAG("test_notifier")
notifier = PagerdutyNotifier(summary="DISK at 99%", severity="critical", action="trigger")
notifier({"dag": dag})
mock_pagerduty_event_hook.return_value.send_event.assert_called_once_with(
@@ -76,9 +69,8 @@ class TestPagerdutyNotifier:
)
@mock.patch("airflow.providers.pagerduty.notifications.pagerduty.PagerdutyEventsHook")
- def test_notifier_templated(self, mock_pagerduty_event_hook, dag_maker):
- with dag_maker("test_notifier") as dag:
- EmptyOperator(task_id="task1")
+ def test_notifier_templated(self, mock_pagerduty_event_hook):
+ dag = DAG("test_notifier")
notifier = PagerdutyNotifier(
summary="DISK at 99% {{dag.dag_id}}",