Skip to content

Commit

Permalink
Resolve pagerduty deprecations in tests (apache#39945)
Browse files Browse the repository at this point in the history
  • Loading branch information
dirrao authored Jun 4, 2024
1 parent ea68238 commit 21dae6e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 19 deletions.
3 changes: 0 additions & 3 deletions tests/deprecations_ignore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -466,9 +466,6 @@
- tests/providers/oracle/hooks/test_oracle.py::TestOracleHookConn::test_set_thick_mode_params
- tests/providers/oracle/hooks/test_oracle.py::TestOracleHookConn::test_thick_mode_defaults_to_false
- tests/providers/oracle/hooks/test_oracle.py::TestOracleHookConn::test_thick_mode_dirs_defaults
- tests/providers/pagerduty/hooks/test_pagerduty.py::TestPagerdutyHook::test_create_event
- tests/providers/pagerduty/hooks/test_pagerduty.py::TestPagerdutyHook::test_create_event_override
- tests/providers/pagerduty/hooks/test_pagerduty_events.py::TestPagerdutyEventsHook::test_create_event
- tests/providers/postgres/hooks/test_postgres.py::TestPostgresHookConn::test_schema_kwarg_database_kwarg_compatibility
- tests/providers/postgres/operators/test_postgres.py::test_parameters_are_templatized
- tests/providers/postgres/operators/test_postgres.py::TestPostgres::test_overwrite_database
Expand Down
31 changes: 20 additions & 11 deletions tests/providers/pagerduty/hooks/test_pagerduty.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import pytest

from airflow.exceptions import AirflowProviderDeprecationWarning
from airflow.models import Connection
from airflow.providers.pagerduty.hooks.pagerduty import PagerdutyHook
from airflow.providers.pagerduty.hooks.pagerduty_events import PagerdutyEventsHook
Expand Down Expand Up @@ -84,11 +85,15 @@ def test_get_service(self, requests_mock):
def test_create_event(self, events_hook_create_event, events_hook_init):
events_hook_init.return_value = None
hook = PagerdutyHook(pagerduty_conn_id=DEFAULT_CONN_ID)
hook.create_event(
summary="test",
source="airflow_test",
severity="error",
)
with pytest.warns(
AirflowProviderDeprecationWarning,
match="This method will be deprecated. Please use the `airflow.providers.pagerduty.hooks.PagerdutyEventsHook` to interact with the Events API",
):
hook.create_event(
summary="test",
source="airflow_test",
severity="error",
)
events_hook_init.assert_called_with(integration_key="integration_key")
events_hook_create_event.assert_called_with(
summary="test",
Expand All @@ -109,10 +114,14 @@ def test_create_event(self, events_hook_create_event, events_hook_init):
def test_create_event_override(self, events_hook_init):
events_hook_init.return_value = None
hook = PagerdutyHook(pagerduty_conn_id=DEFAULT_CONN_ID)
hook.create_event(
routing_key="different_key",
summary="test",
source="airflow_test",
severity="error",
)
with pytest.warns(
AirflowProviderDeprecationWarning,
match="This method will be deprecated. Please use the `airflow.providers.pagerduty.hooks.PagerdutyEventsHook` to interact with the Events API",
):
hook.create_event(
routing_key="different_key",
summary="test",
source="airflow_test",
severity="error",
)
events_hook_init.assert_called_with(integration_key="different_key")
14 changes: 9 additions & 5 deletions tests/providers/pagerduty/hooks/test_pagerduty_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,15 @@ def test_create_event(self, requests_mock, events_connections):
"dedup_key": "samplekeyhere",
}
requests_mock.post("https://events.pagerduty.com/v2/enqueue", json=mock_response_body)
resp = hook.create_event(
summary="test",
source="airflow_test",
severity="error",
)
with pytest.warns(
AirflowProviderDeprecationWarning,
match="This method will be deprecated. Please use the `PagerdutyEventsHook.send_event` to interact with the Events API",
):
resp = hook.create_event(
summary="test",
source="airflow_test",
severity="error",
)
assert resp == mock_response_body

def test_create_change_event(self, requests_mock, events_connections):
Expand Down

0 comments on commit 21dae6e

Please sign in to comment.