@@ -278,7 +278,7 @@ def test_retry_max_count_not_exceeded(self, mock_send_telemetry, extra_params):
278278 THEN the connector issues six request (original plus five retries)
279279 before raising an exception
280280 """
281- with mocked_server_response (status = 404 ) as mock_obj :
281+ with mocked_server_response (status = 429 , headers = { "Retry-After" : "0" } ) as mock_obj :
282282 with pytest .raises (MaxRetryError ) as cm :
283283 extra_params = {** extra_params , ** self ._retry_policy }
284284 with self .connection (extra_params = extra_params ) as conn :
@@ -467,22 +467,21 @@ def test_retry_safe_execute_statement_retry_condition(self, extra_params):
467467 )
468468 def test_retry_abort_close_session_on_404 (self , extra_params , caplog ):
469469 """GIVEN the connector sends a CloseSession command
470- WHEN server sends a 404 (which is normally retried)
471- THEN nothing is retried because 404 means the session already closed
470+ WHEN server sends a 404 (which is not retried since commit 41b28159 )
471+ THEN nothing is retried because 404 is globally non-retryable
472472 """
473473
474- # First response is a Bad Gateway -> Result is the command actually goes through
475- # Second response is a 404 because the session is no longer found
474+ # With the idempotency-based retry refactor, 404 is now globally non-retryable
475+ # regardless of command type. The close() method catches RequestError and proceeds.
476476 responses = [
477- {"status" : 502 , "headers" : {"Retry-After" : "1" }, "redirect_location" : None },
478477 {"status" : 404 , "headers" : {}, "redirect_location" : None },
479478 ]
480479
481480 extra_params = {** extra_params , ** self ._retry_policy }
482481 with self .connection (extra_params = extra_params ) as conn :
483482 with mock_sequential_server_responses (responses ):
483+ # Should not raise an exception, the error is caught internally
484484 conn .close ()
485- assert "Session was closed by a prior request" in caplog .text
486485
487486 @pytest .mark .parametrize (
488487 "extra_params" ,
@@ -493,14 +492,13 @@ def test_retry_abort_close_session_on_404(self, extra_params, caplog):
493492 )
494493 def test_retry_abort_close_operation_on_404 (self , extra_params , caplog ):
495494 """GIVEN the connector sends a CancelOperation command
496- WHEN server sends a 404 (which is normally retried)
497- THEN nothing is retried because 404 means the operation was already canceled
495+ WHEN server sends a 404 (which is not retried since commit 41b28159 )
496+ THEN nothing is retried because 404 is globally non-retryable
498497 """
499498
500- # First response is a Bad Gateway -> Result is the command actually goes through
501- # Second response is a 404 because the session is no longer found
499+ # With the idempotency-based retry refactor, 404 is now globally non-retryable
500+ # regardless of command type. The close() method catches RequestError and proceeds.
502501 responses = [
503- {"status" : 502 , "headers" : {"Retry-After" : "1" }, "redirect_location" : None },
504502 {"status" : 404 , "headers" : {}, "redirect_location" : None },
505503 ]
506504
@@ -515,10 +513,8 @@ def test_retry_abort_close_operation_on_404(self, extra_params, caplog):
515513 # This call guarantees we have an open cursor at the server
516514 curs .execute ("SELECT 1" )
517515 with mock_sequential_server_responses (responses ):
516+ # Should not raise an exception, the error is caught internally
518517 curs .close ()
519- assert (
520- "Operation was canceled by a prior request" in caplog .text
521- )
522518
523519 @pytest .mark .parametrize (
524520 "extra_params" ,
0 commit comments