def test_trackTrail(self): htmlsrc = "<html><head></head>" htmlsrc += "<body>{% track 'trail' 'path/file.ext' %}</body></html>" tag = '{% trackedurl linkid "path/file.ext" %}' htmlres = """<html><head></head><body>{0}</body></html>""".format(tag) text, html = _email.compile_email(htmlsrc) self.assertEquals(text, tag) self.assertEqualsHtml(html, htmlres)
def _compile(self, **kwargs): """Compile the DraftEmail object into an Email object. Do not call directly, instead use send(). """ if not self.subject: self.subject = app_settings.EMAIL_DEFAULT_SUBJECT text, html = _email.compile_email(self.message, **kwargs) u = _create_tracker_for_email() email_model = Email( fromemail=self.fromemail, tracker=u, subject=self.subject, txtmsg=text, htmlmsg=html ) return email_model
def test_header_footer(self): htmlsrc = "<html><head></head><body><p>A paragraph.</p></body></html>" header = '<h1>A Header</h1>' footer = '<div>A footer.</div>' body = "<body>{0}<p>A paragraph.</p>{1}</body>".format(header, footer) htmlres = "<html><head></head>{0}</html>".format(body) textres = "\n{0}\n\nA paragraph.\n{1}".format("A Header", "A footer.") text, html = _email.compile_email(htmlsrc, html_header=header, html_footer=footer) self.assertEquals(text, textres) self.assertEqualsHtml(html, htmlres)
def test_bodycontent(self): htmlsrc = "<html><head></head><body><p>A paragraph.</p></body></html>" text, html = _email.compile_email(htmlsrc) self.assertEquals(text, '\nA paragraph.\n') self.assertEqualsHtml(html, htmlsrc)
def test_headcontent(self): htmlsrc = "<html><head><title>A Title</title></head>" htmlsrc += "<body></body></html>" text, html = _email.compile_email(htmlsrc) self.assertEquals(text, '') self.assertEqualsHtml(html, htmlsrc)
def test_basic(self): htmlsrc = "<html><head></head><body></body></html>" text, html = _email.compile_email(htmlsrc) self.assertEquals(text, '') self.assertEqualsHtml(html, htmlsrc)