You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "eumiro (via GitHub)" <gi...@apache.org> on 2023/08/19 22:25:17 UTC
[GitHub] [airflow] eumiro opened a new pull request, #33542: Refactor: use tmp_path in utils test
eumiro opened a new pull request, #33542:
URL: https://github.com/apache/airflow/pull/33542
(no comment)
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] uranusjr commented on a diff in pull request #33542: Refactor: use tmp_path in utils test
Posted by "uranusjr (via GitHub)" <gi...@apache.org>.
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] potiuk merged pull request #33542: Refactor: use tmp_path in utils test
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk merged PR #33542:
URL: https://github.com/apache/airflow/pull/33542
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] uranusjr commented on a diff in pull request #33542: Refactor: use tmp_path in utils test
Posted by "uranusjr (via GitHub)" <gi...@apache.org>.
uranusjr commented on code in PR #33542:
URL: https://github.com/apache/airflow/pull/33542#discussion_r1299288674
##########
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:
```suggestion
email.send_email_smtp("to", "subject", "content", files=[os.fspath(path)])
```
While `send_email_smtp` actually works for any PathLike[str], we only officially support str.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org