This is an automated email from the ASF dual-hosted git repository.
shahar1 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 b70e056895f Fix stackdriver list alert policies JSON typo (#73148)
b70e056895f is described below
commit b70e056895f6e4bc250e51e508aeb5394cec253c
Author: Shahar Epstein <[email protected]>
AuthorDate: Fri Sep 18 09:40:57 2026 +0300
Fix stackdriver list alert policies JSON typo (#73148)
---
.../providers/google/cloud/hooks/stackdriver.py | 2 +-
.../unit/google/cloud/hooks/test_stackdriver.py | 24 ++++++++++++++++++++++
2 files changed, 25 insertions(+), 1 deletion(-)
diff --git
a/providers/google/src/airflow/providers/google/cloud/hooks/stackdriver.py
b/providers/google/src/airflow/providers/google/cloud/hooks/stackdriver.py
index 761aa48e86a..f74f48f526d 100644
--- a/providers/google/src/airflow/providers/google/cloud/hooks/stackdriver.py
+++ b/providers/google/src/airflow/providers/google/cloud/hooks/stackdriver.py
@@ -126,7 +126,7 @@ class StackdriverHook(GoogleBaseHook):
if format_ == "dict":
return [AlertPolicy.to_dict(policy) for policy in policies_]
if format_ == "json":
- return [AlertPolicy.to_jsoon(policy) for policy in policies_]
+ return [AlertPolicy.to_json(policy) for policy in policies_]
return policies_
@GoogleBaseHook.fallback_to_default_project_id
diff --git a/providers/google/tests/unit/google/cloud/hooks/test_stackdriver.py
b/providers/google/tests/unit/google/cloud/hooks/test_stackdriver.py
index 33c6f7bcd6d..13e93ba90bd 100644
--- a/providers/google/tests/unit/google/cloud/hooks/test_stackdriver.py
+++ b/providers/google/tests/unit/google/cloud/hooks/test_stackdriver.py
@@ -102,6 +102,30 @@ class TestStackdriverHookMethods:
metadata=(),
)
+ @pytest.mark.parametrize(
+ ("format_", "expected_formatter"),
+ [
+ (None, lambda policy: policy),
+ ("dict", AlertPolicy.to_dict),
+ ("json", AlertPolicy.to_json),
+ ],
+ )
+ @mock.patch(
+
"airflow.providers.google.common.hooks.base_google.GoogleBaseHook.get_credentials_and_project_id",
+ return_value=(CREDENTIALS, PROJECT_ID),
+ )
+
@mock.patch("airflow.providers.google.cloud.hooks.stackdriver.StackdriverHook._get_policy_client")
+ def test_stackdriver_list_alert_policies_formats_result(
+ self, mock_policy_client, mock_get_creds_and_project_id, format_,
expected_formatter
+ ):
+ policy = AlertPolicy(**TEST_ALERT_POLICY_1)
+ mock_policy_client.return_value.list_alert_policies.return_value =
[policy]
+ hook = stackdriver.StackdriverHook()
+
+ result = hook.list_alert_policies(project_id=PROJECT_ID,
format_=format_)
+
+ assert result == [expected_formatter(policy)]
+
@mock.patch(
"airflow.providers.google.common.hooks.base_google.GoogleBaseHook.get_credentials_and_project_id",
return_value=(CREDENTIALS, PROJECT_ID),