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 0510f75bcda add unit tests for google/common (#52965)
0510f75bcda is described below

commit 0510f75bcda09e54b36781a84e487e1e4efeb62c
Author: Wei-Yu Chen <[email protected]>
AuthorDate: Sat Jul 19 20:03:25 2025 +0800

    add unit tests for google/common (#52965)
---
 .../tests/unit/google/common/links/__init__.py     | 16 +++++++
 .../tests/unit/google/common/links/test_storage.py | 51 ++++++++++++++++++++++
 .../google/tests/unit/google/common/test_consts.py | 34 +++++++++++++++
 3 files changed, 101 insertions(+)

diff --git a/providers/google/tests/unit/google/common/links/__init__.py 
b/providers/google/tests/unit/google/common/links/__init__.py
new file mode 100644
index 00000000000..13a83393a91
--- /dev/null
+++ b/providers/google/tests/unit/google/common/links/__init__.py
@@ -0,0 +1,16 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
diff --git a/providers/google/tests/unit/google/common/links/test_storage.py 
b/providers/google/tests/unit/google/common/links/test_storage.py
new file mode 100644
index 00000000000..63a8758e108
--- /dev/null
+++ b/providers/google/tests/unit/google/common/links/test_storage.py
@@ -0,0 +1,51 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from __future__ import annotations
+
+from airflow.providers.google.common.links.storage import FileDetailsLink, 
StorageLink
+
+
+class TestStorageLink:
+    def test_storage_link(self):
+        assert StorageLink.name == "GCS Storage"
+        assert StorageLink.key == "storage_conf"
+        assert (
+            StorageLink.format_str
+            == 
"https://console.cloud.google.com/storage/browser/{uri};tab=objects?project={project_id}";
+        )
+
+    def test_storage_link_format(self):
+        link = StorageLink()
+        url = link._format_link(uri="test-bucket/test-folder", 
project_id="test-id")
+        expected_url = 
"https://console.cloud.google.com/storage/browser/test-bucket/test-folder;tab=objects?project=test-id";
+        assert url == expected_url
+
+
+class TestFileDetailsLink:
+    def test_file_details_link_name_and_key(self):
+        assert FileDetailsLink.name == "GCS File Details"
+        assert FileDetailsLink.key == "file_details"
+        assert (
+            FileDetailsLink.format_str
+            == 
"https://console.cloud.google.com/storage/browser/_details/{uri};tab=live_object?project={project_id}";
+        )
+
+    def test_file_details_link_format(self):
+        link = FileDetailsLink()
+        url = link._format_link(uri="test-bucket/test-folder", 
project_id="test-id")
+        expected_url = 
"https://console.cloud.google.com/storage/browser/_details/test-bucket/test-folder;tab=live_object?project=test-id";
+        assert url == expected_url
diff --git a/providers/google/tests/unit/google/common/test_consts.py 
b/providers/google/tests/unit/google/common/test_consts.py
new file mode 100644
index 00000000000..66df4f6473a
--- /dev/null
+++ b/providers/google/tests/unit/google/common/test_consts.py
@@ -0,0 +1,34 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from __future__ import annotations
+
+from google.api_core.gapic_v1.client_info import ClientInfo
+
+from airflow import version
+from airflow.providers.google.common.consts import (
+    CLIENT_INFO,
+    GOOGLE_DEFAULT_DEFERRABLE_METHOD_NAME,
+)
+
+
+def test_google_default_deferrable_method_name():
+    assert GOOGLE_DEFAULT_DEFERRABLE_METHOD_NAME == "execute_complete"
+
+
+def test_client_info_instance():
+    assert isinstance(CLIENT_INFO, ClientInfo)
+    assert CLIENT_INFO.client_library_version == f"airflow_v{version.version}"

Reply via email to