From patchwork Tue Oct 20 21:59:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Lespiau X-Patchwork-Id: 533510 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 8657B1412F7 for ; Wed, 21 Oct 2015 09:00:50 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 6B8ED1A039A for ; Wed, 21 Oct 2015 09:00:50 +1100 (AEDT) X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lists.ozlabs.org (Postfix) with ESMTP id BA1F01A02D0 for ; Wed, 21 Oct 2015 08:59:52 +1100 (AEDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 20 Oct 2015 14:59:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,708,1437462000"; d="scan'208";a="798504510" Received: from jphilipp-mobl5.ger.corp.intel.com (HELO strange.ger.corp.intel.com) ([10.252.19.140]) by orsmga001.jf.intel.com with ESMTP; 20 Oct 2015 14:59:50 -0700 From: Damien Lespiau To: patchwork@lists.ozlabs.org Subject: [PATCH 05/14] tests: Make sure all emails have a valid msgid Date: Tue, 20 Oct 2015 22:59:34 +0100 Message-Id: <1445378383-16977-6-git-send-email-damien.lespiau@intel.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1445378383-16977-1-git-send-email-damien.lespiau@intel.com> References: <1445378383-16977-1-git-send-email-damien.lespiau@intel.com> X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" Messages ids will be used by the Series code as the way to uniquely identify series. We must ensure every single email that goes through the parser has a valid msgid to not fail once we parse series. v2: Rebase on top upstream Signed-off-by: Damien Lespiau Acked-by: Stephen Finucane --- patchwork/tests/test_patchparser.py | 14 +++++++++++--- patchwork/tests/utils.py | 5 +++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/patchwork/tests/test_patchparser.py b/patchwork/tests/test_patchparser.py index fe1fd2a..ab02759 100644 --- a/patchwork/tests/test_patchparser.py +++ b/patchwork/tests/test_patchparser.py @@ -19,6 +19,7 @@ import os from email import message_from_string +from email.utils import make_msgid from django.test import TestCase from patchwork.models import Project, Person, Patch, Comment, State, \ get_default_initial_patch_state @@ -153,7 +154,8 @@ class SenderEncodingTest(TestCase): from_header = 'example user ' def setUp(self): - mail = 'From: %s\n' % self.from_header + \ + mail = 'Message-Id: %s\n' % make_msgid() + \ + 'From: %s\n' % self.from_header + \ 'Subject: test\n\n' + \ 'test' self.email = message_from_string(mail) @@ -195,7 +197,8 @@ class SubjectEncodingTest(PatchTest): subject_header = 'test subject' def setUp(self): - mail = 'From: %s\n' % self.sender + \ + mail = 'Message-Id: %s\n' % make_msgid() + \ + 'From: %s\n' % self.sender + \ 'Subject: %s\n\n' % self.subject_header + \ 'test\n\n' + defaults.patch self.projects = defaults.project @@ -218,7 +221,11 @@ class SenderCorrelationTest(TestCase): non_existing_sender = 'Non-existing Sender ' def mail(self, sender): - return message_from_string('From: %s\nSubject: Test\n\ntest\n' % sender) + mail = 'Message-Id: %s\n' % make_msgid() + \ + 'From: %s\n' % sender + \ + 'Subject: Tests\n\n'\ + 'test\n' + return message_from_string(mail) def setUp(self): self.existing_sender_mail = self.mail(self.existing_sender) @@ -271,6 +278,7 @@ class MultipleProjectPatchTest(TestCase): patch = read_patch(self.patch_filename) email = create_email(self.test_comment + '\n' + patch) + del email['Message-Id'] email['Message-Id'] = self.msgid del email['List-ID'] diff --git a/patchwork/tests/utils.py b/patchwork/tests/utils.py index 15ca3aa..4f4906b 100644 --- a/patchwork/tests/utils.py +++ b/patchwork/tests/utils.py @@ -26,6 +26,8 @@ from django.forms.fields import EmailField from email import message_from_file from email.mime.text import MIMEText from email.mime.multipart import MIMEMultipart +from email.utils import make_msgid + # helper functions for tests _test_mail_dir = os.path.join(os.path.dirname(__file__), 'mail') @@ -102,6 +104,8 @@ def read_patch(filename, encoding = None): def read_mail(filename, project = None): file_path = os.path.join(_test_mail_dir, filename) mail = message_from_file(open(file_path)) + if 'Message-Id' not in mail: + mail['Message-Id'] = make_msgid() if project is not None: mail['List-Id'] = project.listid return mail @@ -125,6 +129,7 @@ def create_email(content, subject = None, sender = None, multipart = False, else: msg = MIMEText(content, _charset = content_encoding) + msg['Message-Id'] = make_msgid() msg['Subject'] = subject msg['From'] = sender msg['List-Id'] = project.listid