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 9c980f7a5c Return back removed public HttpHook's method (#37738)
9c980f7a5c is described below

commit 9c980f7a5c549334dc88f44a6637e87e7892791d
Author: Andrey Anshin <andrey.ans...@taragol.is>
AuthorDate: Tue Feb 27 17:15:15 2024 +0400

    Return back removed public HttpHook's method (#37738)
---
 airflow/providers/http/hooks/http.py    |  4 ++++
 tests/providers/http/hooks/test_http.py | 12 ++++++++++++
 2 files changed, 16 insertions(+)

diff --git a/airflow/providers/http/hooks/http.py 
b/airflow/providers/http/hooks/http.py
index 8631a5b175..0088e65945 100644
--- a/airflow/providers/http/hooks/http.py
+++ b/airflow/providers/http/hooks/http.py
@@ -268,6 +268,10 @@ class HttpHook(BaseHook):
         # TODO: remove ignore type when 
https://github.com/jd/tenacity/issues/428 is resolved
         return self._retry_obj(self.run, *args, **kwargs)  # type: ignore
 
+    def url_from_endpoint(self, endpoint: str | None) -> str:
+        """Combine base url with endpoint."""
+        return _url_from_endpoint(base_url=self.base_url, endpoint=endpoint)
+
     def test_connection(self):
         """Test HTTP Connection."""
         try:
diff --git a/tests/providers/http/hooks/test_http.py 
b/tests/providers/http/hooks/test_http.py
index ae1545a99e..f82189a559 100644
--- a/tests/providers/http/hooks/test_http.py
+++ b/tests/providers/http/hooks/test_http.py
@@ -497,6 +497,18 @@ class TestHttpHook:
             tcp_keep_alive_send.assert_not_called()
             http_send.assert_called()
 
+    @pytest.mark.parametrize(
+        "base_url, endpoint, expected_url",
+        [
+            pytest.param("https://example.org";, "/v1/test", 
"https://example.org/v1/test";, id="both-set"),
+            pytest.param("", "http://foo/bar/v1/test";, 
"http://foo/bar/v1/test";, id="only-endpoint"),
+        ],
+    )
+    def test_url_from_endpoint(self, base_url: str, endpoint: str, 
expected_url: str):
+        hook = HttpHook()
+        hook.base_url = base_url
+        assert hook.url_from_endpoint(endpoint) == expected_url
+
 
 class TestHttpAsyncHook:
     @pytest.mark.asyncio

Reply via email to