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
4 changes: 2 additions & 2 deletions providers/opsgenie/tests/unit/opsgenie/hooks/test_opsgenie.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
from airflow.models import Connection
from airflow.providers.opsgenie.hooks.opsgenie import OpsgenieAlertHook

pytestmark = pytest.mark.db_test


class TestOpsgenieAlertHook:
conn_id = "opsgenie_conn_id_test"
Expand Down Expand Up @@ -83,6 +81,7 @@ def test_get_api_key(self):
api_key = hook._get_api_key()
assert api_key == "eb243592-faa2-4ba2-a551q-1afdf565c889"

@pytest.mark.db_test
def test_get_conn_defaults_host(self):
hook = OpsgenieAlertHook()
assert hook.get_conn().api_client.configuration.host == "https://api.opsgenie.com"
Expand All @@ -108,6 +107,7 @@ def test_verify_api_key_set(self):
== "eb243592-faa2-4ba2-a551q-1afdf565c889"
)

@pytest.mark.db_test
def test_create_alert_api_key_not_set(self):
hook = OpsgenieAlertHook()
with pytest.raises(AuthenticationException):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
from airflow.providers.opsgenie.notifications.opsgenie import OpsgenieNotifier, send_opsgenie_notification
from airflow.providers.standard.operators.empty import EmptyOperator

pytestmark = pytest.mark.db_test


class TestOpsgenieNotifier:
_config = {
Expand Down Expand Up @@ -76,6 +74,7 @@ class TestOpsgenieNotifier:
}

@mock.patch.object(OpsgenieAlertHook, "get_conn")
@pytest.mark.db_test
def test_notifier(self, mock_opsgenie_alert_hook, dag_maker):
with dag_maker("test_notifier") as dag:
EmptyOperator(task_id="task1")
Expand All @@ -84,6 +83,7 @@ def test_notifier(self, mock_opsgenie_alert_hook, dag_maker):
mock_opsgenie_alert_hook.return_value.create_alert.assert_called_once_with(self.expected_payload_dict)

@mock.patch.object(OpsgenieAlertHook, "get_conn")
@pytest.mark.db_test
def test_notifier_with_notifier_class(self, mock_opsgenie_alert_hook, dag_maker):
with dag_maker("test_notifier") as dag:
EmptyOperator(task_id="task1")
Expand All @@ -92,6 +92,7 @@ def test_notifier_with_notifier_class(self, mock_opsgenie_alert_hook, dag_maker)
mock_opsgenie_alert_hook.return_value.create_alert.assert_called_once_with(self.expected_payload_dict)

@mock.patch.object(OpsgenieAlertHook, "get_conn")
@pytest.mark.db_test
def test_notifier_templated(self, mock_opsgenie_alert_hook, dag_maker):
dag_id = "test_notifier"
with dag_maker(dag_id) as dag:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,8 @@
# under the License.
from __future__ import annotations

import pytest

from airflow.providers.opsgenie.typing.opsgenie import CreateAlertPayload

pytestmark = pytest.mark.db_test


class TestCreateAlertPayload:
def test_create_alert_payload_required_keys(self):
Expand Down