uranusjr commented on code in PR #33542:
URL: https://github.com/apache/airflow/pull/33542#discussion_r1299288708


##########
tests/utils/test_email.py:
##########
@@ -148,23 +146,22 @@ def test_build_mime_message(self):
 
 class TestEmailSmtp:
     @mock.patch("airflow.utils.email.send_mime_email")
-    def test_send_smtp(self, mock_send_mime):
-        with tempfile.NamedTemporaryFile() as attachment:
-            attachment.write(b"attachment")
-            attachment.seek(0)
-            email.send_email_smtp("to", "subject", "content", 
files=[attachment.name])
-            assert mock_send_mime.called
-            _, call_args = mock_send_mime.call_args
-            assert conf.get("smtp", "SMTP_MAIL_FROM") == call_args["e_from"]
-            assert ["to"] == call_args["e_to"]
-            msg = call_args["mime_msg"]
-            assert "subject" == msg["Subject"]
-            assert conf.get("smtp", "SMTP_MAIL_FROM") == msg["From"]
-            assert 2 == len(msg.get_payload())
-            filename = 'attachment; filename="' + 
os.path.basename(attachment.name) + '"'
-            assert filename == msg.get_payload()[-1].get("Content-Disposition")
-            mimeapp = MIMEApplication("attachment")
-            assert mimeapp.get_payload() == msg.get_payload()[-1].get_payload()
+    def test_send_smtp(self, mock_send_mime, tmp_path):
+        path = tmp_path / "testfile"
+        path.write_bytes(b"attachment")
+        email.send_email_smtp("to", "subject", "content", files=[path])

Review Comment:
   Same for other tests



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