Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions emails/testsuite/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
import random
import sys
import platform
import os
import functools
import threading
from http.server import SimpleHTTPRequestHandler, ThreadingHTTPServer


logging.basicConfig(level=logging.DEBUG)
Expand All @@ -14,6 +18,37 @@
import cssutils
cssutils.log.setLevel(logging.FATAL)

import emails.utils

TESTSUITE_ROOT = os.path.dirname(__file__)


class _QuietHandler(SimpleHTTPRequestHandler):
def log_message(self, *args):
pass


@pytest.fixture(scope='session')
def _http_fixtures_server():
handler = functools.partial(_QuietHandler, directory=TESTSUITE_ROOT)
server = ThreadingHTTPServer(('127.0.0.1', 0), handler)
thread = threading.Thread(target=server.serve_forever, daemon=True)
thread.start()
yield 'http://127.0.0.1:%s/' % server.server_address[1]
server.shutdown()
server.server_close()


@pytest.fixture
def http_fixtures(_http_fixtures_server, monkeypatch):
"""
Base url of a local HTTP server that serves files from emails/testsuite,
e.g. http_fixtures + 'data/http/python-logo.gif'.
Fetching from loopback is allowed while the fixture is active.
"""
monkeypatch.setattr(emails.utils, 'url_validator', None)
return _http_fixtures_server


@pytest.fixture(scope='module')
def django_email_backend(request):
Expand Down
Binary file added emails/testsuite/data/http/python-logo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
301 changes: 301 additions & 0 deletions emails/testsuite/data/http/sample-template/template-widgets.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,301 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Campaign Monitor Newsletter</title>
<style>
a:hover {
text-decoration: underline !important;
}
td.promocell p {
color:#e1d8c1;
font-size:16px;
line-height:26px;
font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;
margin-top:0;
margin-bottom:0;
padding-top:0;
padding-bottom:14px;
font-weight:normal;
}
td.contentblock h4 {
color:#444444 !important;
font-size:16px;
line-height:24px;
font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;
margin-top:0;
margin-bottom:10px;
padding-top:0;
padding-bottom:0;
font-weight:normal;
}
td.contentblock h4 a {
color:#444444;
text-decoration:none;
}
td.contentblock p {
color:#888888;
font-size:13px;
line-height:19px;
font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;
margin-top:0;
margin-bottom:12px;
padding-top:0;
padding-bottom:0;
font-weight:normal;
}
td.contentblock p a {
color:#3ca7dd;
text-decoration:none;
}
@media only screen and (max-device-width: 480px) {
div[class="header"] {
font-size: 16px !important;
}
table[class="table"], td[class="cell"] {
width: 300px !important;
}
table[class="promotable"], td[class="promocell"] {
width: 325px !important;
}
td[class="footershow"] {
width: 300px !important;
}
table[class="hide"], img[class="hide"], td[class="hide"] {
display: none !important;
}
img[class="divider"] {
height: 1px !important;
}
td[class="logocell"] {
padding-top: 15px !important;
padding-left: 15px !important;
width: 300px !important;
}
img[id="screenshot"] {
width: 325px !important;
height: 127px !important;
}
img[class="galleryimage"] {
width: 53px !important;
height: 53px !important;
}
p[class="reminder"] {
font-size: 11px !important;
}
h4[class="secondary"] {
line-height: 22px !important;
margin-bottom: 15px !important;
font-size: 18px !important;
}
}
</style>
</head>
<body bgcolor="#e4e4e4" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0" style="-webkit-font-smoothing: antialiased;width:100% !important;background:#e4e4e4;-webkit-text-size-adjust:none;">

<table width="100%" cellpadding="0" cellspacing="0" border="0" bgcolor="#e4e4e4">
<tr>
<td bgcolor="#e4e4e4" width="100%">

<table width="600" cellpadding="0" cellspacing="0" border="0" align="center" class="table">
<tr>
<td width="600" class="cell">

<table width="600" cellpadding="0" cellspacing="0" border="0" class="table">
<tr>
<td width="250" bgcolor="#e4e4e4" class="logocell"><img border="0" src="images/spacer.gif" width="1" height="20" class="hide"><br class="hide"><img src="images/widget-logo4.png" width="178" height="76" alt="Campaign Monitor" style="-ms-interpolation-mode:bicubic;"><br><img border="0" src="images/spacer.gif" width="1" height="10" class="hide"><br class="hide"></td>
<td align="right" width="350" class="hide" style="color:#a6a6a6;font-size:12px;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;text-shadow: 0 1px 0 #ffffff;" valign="top" bgcolor="#e4e4e4"><img border="0" src="images/spacer.gif" width="1" height="63"><br><span>WIDGET&nbsp;</span><strong><span style="text-transform:uppercase;"> <currentmonthname> <currentyear></span></strong> <span>NEWSLETTER&nbsp;</span></td>
</tr>
</table>

<img border="0" src="images/widget-hero3.png" label="Hero image" editable="true" width="600" height="253" id="screenshot">

<table width="600" cellpadding="25" cellspacing="0" border="0" class="promotable">
<tr>
<td bgcolor="#456265" width="600" class="promocell">

<multiline label="Main feature intro"><p>Main feature introduction</p></multiline>

</td>
</tr>
</table>

<img border="0" src="images/spacer.gif" width="1" height="15" class="divider"><br>

<repeater>
<layout label="New feature">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td bgcolor="#85bdad" nowrap><img border="0" src="images/spacer.gif" width="5" height="1"></td>
<td width="100%" bgcolor="#ffffff">

<table width="100%" cellpadding="20" cellspacing="0" border="0">
<tr>
<td bgcolor="#ffffff" class="contentblock">

<h4 class="secondary"><strong><singleline label="Title">Title of new feature</singleline></strong></h4>
<multiline label="Description"><p>A short explanation of the new feature</p></multiline>

</td>
</tr>
</table>

</td>
</tr>
</table>
<img border="0" src="images/spacer.gif" width="1" height="15" class="divider"><br>
</layout>
<layout label="Article, tip or resource">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td bgcolor="#ef3101" nowrap><img border="0" src="images/spacer.gif" width="5" height="1"></td>
<td width="100%" bgcolor="#ffffff">

<table width="100%" cellpadding="20" cellspacing="0" border="0">
<tr>
<td bgcolor="#ffffff" class="contentblock">

<h4 class="secondary"><strong><singleline label="Title">Title of article/tip/resource</singleline></strong></h4>
<multiline label="Description"><p>Description</p></multiline>

</td>
</tr>
</table>

</td>
</tr>
</table>
<img border="0" src="images/spacer.gif" width="1" height="15" class="divider"><br>
</layout>
<layout label="Gallery highlights">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td bgcolor="#832701" nowrap><img border="0" src="images/spacer.gif" width="5" height="1"></td>
<td width="100%" bgcolor="#ffffff">

<table width="100%" cellpadding="20" cellspacing="0" border="0">
<tr>
<td bgcolor="#ffffff" class="contentblock">

<h4 class="secondary"><strong><singleline label="Gallery title">Title of gallery summary</singleline></strong></h4>
<multiline label="Gallery description"><p>Description of this month's gallery entries</p></multiline>

</td>
</tr>
</table>

</td>
</tr>
</table>

<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td bgcolor="#832701" nowrap><img border="0" src="images/spacer.gif" width="5" height="1"></td>
<td bgcolor="#ffffff" nowrap><img border="0" src="images/spacer.gif" width="5" height="1"></td>
<td width="100%" bgcolor="#ffffff">

<table cellpadding="5" cellspacing="0" border="0">
<tr>
<td><img border="0" src="images/gallery.png" width="107" height="107" editable="true" class="galleryimage" label="Image 1"></td>
<td><img border="0" src="images/gallery.png" width="107" height="107" editable="true" class="galleryimage" label="Image 2"></td>
<td><img border="0" src="images/gallery.png" width="107" height="107" editable="true" class="galleryimage" label="Image 3"></td>
<td><img border="0" src="images/gallery.png" width="107" height="107" editable="true" class="galleryimage" label="Image 4"></td>
<td><img border="0" src="images/gallery.png" width="107" height="107" editable="true" class="galleryimage" label="Image 5"></td>
</tr>
<tr>
<td><img border="0" src="images/gallery.png" width="107" height="107" editable="true" class="galleryimage" label="Image 6"></td>
<td><img border="0" src="images/gallery.png" width="107" height="107" editable="true" class="galleryimage" label="Image 7"></td>
<td><img border="0" src="images/gallery.png" width="107" height="107" editable="true" class="galleryimage" label="Image 8"></td>
<td><img border="0" src="images/gallery.png" width="107" height="107" editable="true" class="galleryimage" label="Image 9"></td>
<td><img border="0" src="images/gallery.png" width="107" height="107" editable="true" class="galleryimage" label="Image 10"></td>
</tr>
</table>

<img border="0" src="images/spacer.gif" width="1" height="5"><br>

</td>
</tr>
</table>
<img border="0" src="images/spacer.gif" width="1" height="15" class="divider"><br>
</layout>
<layout label="Pull quote">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td bgcolor="#85bdad" nowrap><img border="0" src="images/spacer.gif" width="5" height="1"></td>
<td width="100%" bgcolor="#ffffff">

<table width="100%" cellpadding="20" cellspacing="0" border="0">
<tr>
<td bgcolor="#ffffff" class="contentblock">

<h4 class="secondary"><strong><singleline label="Pull quote">Enter the quote in full</singleline></strong></h4>

</td>
</tr>
</table>

</td>
</tr>
</table>
<img border="0" src="images/spacer.gif" width="1" height="15" class="divider"><br>
</layout>
</repeater>

</td>
</tr>
</table>

<img border="0" src="images/spacer.gif" width="1" height="25" class="divider"><br>

<table width="100%" cellpadding="0" cellspacing="0" border="0" bgcolor="#f2f2f2">
<tr>
<td>

<img border="0" src="images/spacer.gif" width="1" height="30"><br>

<table width="600" cellpadding="0" cellspacing="0" border="0" align="center" class="table">
<tr>
<td width="600" nowrap bgcolor="#f2f2f2" class="cell">

<table width="600" cellpadding="0" cellspacing="0" border="0" class="table">
<tr>
<td width="380" valign="top" class="footershow">

<img border="0" src="images/spacer.gif" width="1" height="8"><br>

<p style="color:#a6a6a6;font-size:12px;font-family:Helvetica,Arial,sans-serif;margin-top:0;margin-bottom:15px;padding-top:0;padding-bottom:0;line-height:18px;" class="reminder">You’re receiving this because you’re an awesome ABC Widgets customer or subscribed via <a href="http://www.abcwidgets.com/" style="color:#a6a6a6;text-decoration:underline;">our site</a>.</p>
<p style="color:#c9c9c9;font-size:12px;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;"><preferences style="color:#3ca7dd;text-decoration:none;"><strong>Edit your subscription</strong></preferences>&nbsp;&nbsp;|&nbsp;&nbsp;<unsubscribe style="color:#3ca7dd;text-decoration:none;"><strong>Unsubscribe instantly</strong></unsubscribe></p>

</td>
<td align="right" width="220" style="color:#a6a6a6;font-size:12px;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;text-shadow: 0 1px 0 #ffffff;" valign="top" class="hide">

<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td><a href="http://www.flickr.com/photos/freshview"><img border="0" src="images/flickr.gif" width="42" height="32" alt="See our photos on Flickr"></a></td>
<td><a href="http://twitter.com/campaignmonitor"><img border="0" src="images/twitter.gif" width="42" height="32" alt="Follow us on Twitter"></a></td>
<td><a href="http://www.facebook.com/campaignmonitor"><img border="0" src="images/facebook.gif" width="32" height="32" alt="Visit us on Facebook"></a></td>
</tr>
</table>

<img border="0" src="images/spacer.gif" width="1" height="10"><br><p style="color:#b3b3b3;font-size:11px;line-height:15px;font-family:Helvetica,Arial,sans-serif;margin-top:0;margin-bottom:0;padding-top:0;padding-bottom:0;font-weight:bold;">ABC Widgets</p><p style="color:#b3b3b3;font-size:11px;line-height:15px;font-family:Helvetica,Arial,sans-serif;margin-top:0;margin-bottom:0;padding-top:0;padding-bottom:0;font-weight:normal;">87 Street Avenue, California, USA</p></td>
</tr>
</table>

</td>
</tr>
</table>

<img border="0" src="images/spacer.gif" width="1" height="25"><br>

</td>
</tr>
</table>

</td>
</tr>
</table>

</body>
</html>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading