1 # Patchwork - automated patch tracking system
2 # Copyright (C) 2008 Jeremy Kerr <jk@ozlabs.org>
4 # This file is part of the Patchwork package.
6 # Patchwork is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # Patchwork is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with Patchwork; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 from patchwork.models import Project
23 from email.mime.text import MIMEText
24 from email.mime.multipart import MIMEMultipart
26 # Python 2.4 compatibility
27 from email.MIMEText import MIMEText
28 from email.MIMEMultipart import MIMEMultipart
30 # helper functions for tests
31 _test_mail_dir = 'patchwork/tests/mail'
32 _test_patch_dir = 'patchwork/tests/patches'
34 class defaults(object):
35 project = Project(linkname = 'test-project', name = 'Test Project')
37 patch_author = 'Patch Author <patch-author@example.com>'
39 comment_author = 'Comment Author <comment-author@example.com>'
41 sender = 'Test Author <test-author@example.com>'
43 subject = 'Test Subject'
45 patch_name = 'Test Patch'
48 def read_patch(filename):
49 return file(os.path.join(_test_patch_dir, filename)).read()
51 def create_email(content, subject = None, sender = None, multipart = False,
54 subject = defaults.subject
56 sender = defaults.sender
58 project = defaults.project
62 body = MIMEText(content, _subtype = 'plain')
65 msg = MIMEText(content)
67 msg['Subject'] = subject
69 msg['List-Id'] = project.linkname