amoghrajesh commented on code in PR #45431:
URL: https://github.com/apache/airflow/pull/45431#discussion_r1904222541


##########
task_sdk/tests/api/test_client.py:
##########
@@ -362,16 +362,32 @@ def handle_request(request: httpx.Request) -> 
httpx.Response:
 
         client = make_client(transport=httpx.MockTransport(handle_request))
 
-        with pytest.raises(ServerResponseError) as err:
-            client.variables.get(key="non_existent_var")
-
-        assert err.value.response.status_code == 404
-        assert err.value.detail == {
-            "detail": {
-                "message": "Variable with key 'non_existent_var' not found",
-                "reason": "not_found",
-            }
-        }
+        resp = client.variables.get(key="non_existent_var")
+
+        assert isinstance(resp, ErrorResponse)
+        assert resp.error == ErrorType.VARIABLE_NOT_FOUND
+        assert resp.detail == {"key": "non_existent_var"}
+
+    @mock.patch("time.sleep", return_value=None)
+    def test_variable_get_500_error(self, mock_sleep):

Review Comment:
   Reference: https://github.com/apache/airflow/pull/45344#r1900781515
   
   This has been added so that in case there is any sort of internal server 
error or any non "404" error, we handle it gracefully and do not return 
something absurd like: `name 'resp' is not defined`



-- 
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