sunank200 commented on code in PR #29038:
URL: https://github.com/apache/airflow/pull/29038#discussion_r1105711509


##########
tests/providers/http/hooks/test_http.py:
##########
@@ -392,3 +394,95 @@ def test_keep_alive_disabled(self):
 
 
 send_email_test = mock.Mock()
+
+
[email protected]
+def aioresponse():
+    """
+    Creates an mock async API response.
+    This comes from a mock library specific to the aiohttp package:
+    https://github.com/pnuckowski/aioresponses
+
+    """
+    with aioresponses() as async_response:
+        yield async_response
+
+
[email protected]
+async def test_do_api_call_async_non_retryable_error(aioresponse):
+    """Test api call asynchronously with non retryable error."""
+    hook = HttpAsyncHook(method="GET")
+    aioresponse.get("http://httpbin.org/non_existent_endpoint";, status=400)
+
+    with pytest.raises(AirflowException) as exc, mock.patch.dict(
+        "os.environ",
+        AIRFLOW_CONN_HTTP_DEFAULT="http://httpbin.org/";,
+    ):
+        await hook.run(endpoint="non_existent_endpoint")
+
+    assert str(exc.value) == "400:Bad Request"
+
+
[email protected]
+async def test_do_api_call_async_retryable_error(caplog, aioresponse):
+    """Test api call asynchronously with retryable error."""
+    caplog.set_level(logging.WARNING, 
logger="airflow.providers.http.hooks.http")
+    hook = HttpAsyncHook(method="GET")
+    aioresponse.get("http://httpbin.org/non_existent_endpoint";, status=500, 
repeat=True)

Review Comment:
   Removed this: 
https://github.com/apache/airflow/pull/29038/commits/0a1e683db65440452c5c8317c41798f12a8823c0



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to