Skip to content

Commit

Permalink
Return back removed public HttpHook's method (#37738)
Browse files Browse the repository at this point in the history
  • Loading branch information
Taragolis committed Feb 27, 2024
1 parent 8e42a2e commit 9c980f7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions airflow/providers/http/hooks/http.py
Expand Up @@ -268,6 +268,10 @@ def run_with_advanced_retry(self, _retry_args: dict[Any, Any], *args: Any, **kwa
# 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:
Expand Down
12 changes: 12 additions & 0 deletions tests/providers/http/hooks/test_http.py
Expand Up @@ -497,6 +497,18 @@ def test_keep_alive_disabled(self):
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
Expand Down

0 comments on commit 9c980f7

Please sign in to comment.