(self)
| 63 | assert msg.get("Content-Type") == "text/html" |
| 64 | |
| 65 | def test_send_attach(self): |
| 66 | attach = BytesIO() |
| 67 | attach.write(b"content") |
| 68 | attach.seek(0) |
| 69 | attachs = [("attachment", "text/plain", attach)] |
| 70 | |
| 71 | mailsender = MailSender(debug=True) |
| 72 | mailsender.send( |
| 73 | to=["test@scrapy.org"], |
| 74 | subject="subject", |
| 75 | body="body", |
| 76 | attachs=attachs, |
| 77 | _callback=self._catch_mail_sent, |
| 78 | ) |
| 79 | |
| 80 | assert self.catched_msg |
| 81 | assert self.catched_msg["to"] == ["test@scrapy.org"] |
| 82 | assert self.catched_msg["subject"] == "subject" |
| 83 | assert self.catched_msg["body"] == "body" |
| 84 | |
| 85 | msg = self.catched_msg["msg"] |
| 86 | assert msg["to"] == "test@scrapy.org" |
| 87 | assert msg["subject"] == "subject" |
| 88 | |
| 89 | payload = msg.get_payload() |
| 90 | assert isinstance(payload, list) |
| 91 | assert len(payload) == 2 |
| 92 | |
| 93 | text, attach = payload |
| 94 | assert text.get_payload(decode=True) == b"body" |
| 95 | assert text.get_charset() == Charset("us-ascii") |
| 96 | assert attach.get_payload(decode=True) == b"content" |
| 97 | |
| 98 | def test_send_utf8(self): |
| 99 | subject = "sübjèçt" |
nothing calls this directly
no test coverage detected