Ticket #13364: t13364-test.diff
File t13364-test.diff, 2.5 KB (added by , 15 years ago) |
---|
-
new file tests/regressiontests/mail/templates/mail/output.html
diff --git a/tests/regressiontests/mail/templates/mail/output.html b/tests/regressiontests/mail/templates/mail/output.html new file mode 100644
- + 1 <p><strong>Mr. {{ user }}</strong>: Pay us $ {{ amt }} before next Friday.</p> -
new file tests/regressiontests/mail/templates/mail/output.txt
diff --git a/tests/regressiontests/mail/templates/mail/output.txt b/tests/regressiontests/mail/templates/mail/output.txt new file mode 100644
- + 1 {{ user }}: This is an important message. You owe us $ {{ amt }}. -
tests/regressiontests/mail/tests.py
diff --git a/tests/regressiontests/mail/tests.py b/tests/regressiontests/mail/tests.py
a b 14 14 >>> from django.core.mail.backends.base import BaseEmailBackend 15 15 >>> from django.core.mail.backends import console, dummy, locmem, filebased, smtp 16 16 >>> from django.utils.translation import ugettext_lazy 17 >>> from django.template import Context, loader 17 18 18 19 # Test normal ascii character case: 19 20 … … 204 205 JVBERi0xLjQuJS4uLg== 205 206 ... 206 207 208 # #13364 209 >>> subject, from_email, to = 'hello', 'from@example.com', '"Surname, Firstname" <to@example.com>' 210 >>> ctx = Context({'user': 'Joe', 'amt': '1000.00'}) 211 >>> text_template = loader.get_template('mail/output.txt') 212 >>> html_template = loader.get_template('mail/output.html') 213 >>> text_content = text_template.render(ctx) 214 >>> html_content = html_template.render(ctx) 215 >>> msg = EmailMultiAlternatives('Message from Firstname Surname', text_content, from_email, [to]) 216 >>> msg.attach_alternative(html_content, "text/html") 217 >>> print msg.message().as_string() 218 Content-Type: multipart/alternative; boundary="..." 219 MIME-Version: 1.0 220 Subject: Message from Firstname Surname 221 From: from@example.com 222 To: "Surname, Firstname" <to@example.com> 223 Date: ... 224 Message-ID: ... 225 <BLANKLINE> 226 ... 227 Content-Type: text/plain; charset="utf-8" 228 MIME-Version: 1.0 229 Content-Transfer-Encoding: quoted-printable 230 <BLANKLINE> 231 Joe: This is an important message. You owe us $ 1000.00. 232 <BLANKLINE> 233 ... 234 Content-Type: text/html; charset="utf-8" 235 MIME-Version: 1.0 236 Content-Transfer-Encoding: quoted-printable 237 <BLANKLINE> 238 <p><strong>Mr. Joe</strong>: Pay us $ 1000.00 before next Friday.</p> 239 <BLANKLINE> 240 ... 241 207 242 # Make sure that the console backend writes to stdout by default 208 243 >>> connection = console.EmailBackend() 209 244 >>> email = EmailMessage('Subject', 'Content', 'bounce@example.com', ['to@example.com'], headers={'From': 'from@example.com'})