]> git.ozlabs.org Git - patchwork/blobdiff - apps/patchwork/tests/utils.py
Add support for git-pull requests
[patchwork] / apps / patchwork / tests / utils.py
index 5dc5d16e47dd46997750ee3fd3bf529ec80b5134..a85e168d38753667f4fed458132414ac0c4034f8 100644 (file)
@@ -22,6 +22,7 @@ import codecs
 from patchwork.models import Project, Person, UserProfile
 from django.contrib.auth.models import User
 
+from email import message_from_file
 try:
     from email.mime.text import MIMEText
     from email.mime.multipart import MIMEMultipart
@@ -91,6 +92,13 @@ def read_patch(filename, encoding = None):
 
     return f.read()
 
+def read_mail(filename, project = None):
+    file_path = os.path.join(_test_mail_dir, filename)
+    mail = message_from_file(open(file_path))
+    if project is not None:
+        mail['List-Id'] = project.listid
+    return mail
+
 def create_email(content, subject = None, sender = None, multipart = False,
         project = None, content_encoding = None):
     if subject is None: