shivaam commented on code in PR #74185:
URL: https://github.com/apache/airflow/pull/74185#discussion_r4349754299


##########
providers/smtp/tests/unit/smtp/hooks/test_smtp.py:
##########
@@ -720,6 +753,61 @@ async def test_async_connection(
         assert mock_smtp_client.auth_login.await_count == 1
         mock_smtp_client.auth_login.assert_awaited_once_with(SMTP_LOGIN, 
SMTP_PASSWORD)
 
+    @pytest.mark.parametrize("failed_step", ["starttls", "ehlo", "auth_login", 
"auth_xoauth2"])
+    @pytest.mark.parametrize("cleanup_fails", [False, True])
+    async def test_discards_failed_setup(self, mock_get_connection, 
failed_step, cleanup_fails):
+        failed_client = mock.create_autospec(aiosmtplib.SMTP, instance=True)
+        healthy_client = mock.create_autospec(aiosmtplib.SMTP, instance=True)
+        for client in (failed_client, healthy_client):
+            client.auth_login = AsyncMock()
+            client.auth_xoauth2 = AsyncMock()
+        setup_error = OSError("setup failed")

Review Comment:
   Nonblocking nit: could we also cover `asyncio.CancelledError` here and in 
the `_abuild_client` failure tests? The `OSError` cases exercise cleanup, but 
would still pass if `except BaseException` were narrowed to `except Exception`. 
A cancellation case would protect closing the client and propagating the 
original cancellation.
   
   ---
   Drafted-by: Codex (no human review of this comment text before posting)



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