Created
May 24, 2021 03:42
-
-
Save anandology/f3be96a32e23507c1284d23b6ec76084 to your computer and use it in GitHub Desktop.
email test using py.test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def test_sendmail(monkeypatch): | |
emails = [] | |
def mock_sendmail(self, from_addr, to_addrs, msg, mail_options=(), rcpt_options=()): | |
emails.append(dict(from_addr=from_addr, to_addrs=to_addrs, msg=msg)) | |
monkeypatch.setattr(smtplib.SMTP, "sendmail", mock_sendmail) | |
frappe.sendmail( | |
recipients=['[email protected]'], | |
sender='[email protected]', | |
subject='Test Mail', | |
message='Dear Test, welcome!', | |
delayed=False) | |
assert len(emails) == 1 | |
email = emails[0] | |
assert email['from_addr'] == '[email protected]' | |
assert email['to_addrs'] == ['[email protected]'] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment