Commits

Patrick Mézard committed 86c1fe2

makembox: simplify, read messages from files

  • Participants
  • Parent commits 67cbeed

Comments (0)

Files changed (5)

File tests/makembox.py

 #
 import email, mailbox, os
 
-def makemsg(payload, fromname='Bar Baz <barbaz@gmail.com>', subject='test diff'):
-    header = """\
-Delivered-To: foobar@gmail.com
-Received: by 10.114.108.3 with SMTP id g3cs509927wac;
-        Mon, 29 Dec 2008 17:13:30 -0800 (PST)
-MIME-Version: 1.0
-Subject: [PATCH] %(subject)s
-Message-Id: <5ab3c4562bd574dbd782.1230599538@localhost>
-Date: Tue, 30 Dec 2008 02:12:18 +0100
-From: %(fromname)s
-To: mercurial-devel@selenic.com
-Content-Type: text/plain; charset="us-ascii"
-Content-Transfer-Encoding: 7bit
-Sender: mercurial-devel-bounces@selenic.com
-""" % {'fromname': fromname,
-       'subject': subject}
-    footer = """\
-_______________________________________________
-Mercurial-devel mailing list
-Mercurial-devel@selenic.com
-http://selenic.com/mailman/listinfo/mercurial-devel
-"""
-    return header + payload + footer
-
 # Fill the test mailbox
 os.remove('test.mbx')
 mbox = mailbox.mbox('test.mbx')
 
-msg = makemsg("""\
-test diff
-
-diff --git a/a b/a
-new file mode 100644
---- /dev/null
-+++ b/a
-@@ -0,0 +1,1 @@
-+a
-
-""", subject='patch1')
-mbox.add(email.message_from_string(msg))
+mbox.add(email.message_from_file(file('msg1')))
 
 # Add a different patch with the same name from the same author
 # It should hide the previous one
-msg = makemsg("""\
-test diff
+mbox.add(email.message_from_file(file('msg2')))
 
-diff --git a/a b/a
-new file mode 100644
---- /dev/null
-+++ b/a
-@@ -0,0 +1,1 @@
-+b
-
-""", subject='patch1')
-mbox.add(email.message_from_string(msg))
-
-# Another patch with another title
-msg = makemsg("""\
-test diff
-
-diff --git a/a b/a
-new file mode 100644
---- /dev/null
-+++ b/a
-@@ -0,0 +1,1 @@
-+c
-
-""", subject='patch2')
-mbox.add(email.message_from_string(msg))
+# Another a patch with a different title
+mbox.add(email.message_from_file(file('msg3')))
 
 mbox.close()
+Delivered-To: foobar@gmail.com
+Received: by 10.114.108.3 with SMTP id g3cs509927wac;
+        Mon, 29 Dec 2008 17:13:30 -0800 (PST)
+MIME-Version: 1.0
+Subject: [PATCH] patch1
+Message-Id: <5ab3c4562bd574dbd782.1230599538@localhost>
+Date: Tue, 30 Dec 2008 02:12:18 +0100
+From: Bar Baz <barbaz@gmail.com>
+To: mercurial-devel@selenic.com
+Content-Type: text/plain; charset="us-ascii"
+Content-Transfer-Encoding: 7bit
+Sender: mercurial-devel-bounces@selenic.com
+
+test diff
+
+diff --git a/a b/a
+new file mode 100644
+--- /dev/null
++++ b/a
+@@ -0,0 +1,1 @@
++a
+
+_______________________________________________
+Mercurial-devel mailing list
+Mercurial-devel@selenic.com
+http://selenic.com/mailman/listinfo/mercurial-devel
+Delivered-To: foobar@gmail.com
+Received: by 10.114.108.3 with SMTP id g3cs509927wac;
+        Mon, 29 Dec 2008 17:13:30 -0800 (PST)
+MIME-Version: 1.0
+Subject: [PATCH] patch1
+Message-Id: <5ab3c4562bd574dbd782.1230599538@localhost>
+Date: Tue, 30 Dec 2008 02:12:18 +0100
+From: Bar Baz <barbaz@gmail.com>
+To: mercurial-devel@selenic.com
+Content-Type: text/plain; charset="us-ascii"
+Content-Transfer-Encoding: 7bit
+Sender: mercurial-devel-bounces@selenic.com
+
+test diff
+
+diff --git a/a b/a
+new file mode 100644
+--- /dev/null
++++ b/a
+@@ -0,0 +1,1 @@
++b
+
+_______________________________________________
+Mercurial-devel mailing list
+Mercurial-devel@selenic.com
+http://selenic.com/mailman/listinfo/mercurial-devel
+Delivered-To: foobar@gmail.com
+Received: by 10.114.108.3 with SMTP id g3cs509927wac;
+        Mon, 29 Dec 2008 17:13:30 -0800 (PST)
+MIME-Version: 1.0
+Subject: [PATCH] patch2
+Message-Id: <5ab3c4562bd574dbd782.1230599538@localhost>
+Date: Tue, 30 Dec 2008 02:12:18 +0100
+From: Bar Baz <barbaz@gmail.com>
+To: mercurial-devel@selenic.com
+Content-Type: text/plain; charset="us-ascii"
+Content-Transfer-Encoding: 7bit
+Sender: mercurial-devel-bounces@selenic.com
+
+test diff
+
+diff --git a/a b/a
+new file mode 100644
+--- /dev/null
++++ b/a
+@@ -0,0 +1,1 @@
++c
+
+_______________________________________________
+Mercurial-devel mailing list
+Mercurial-devel@selenic.com
+http://selenic.com/mailman/listinfo/mercurial-devel

File tests/test.mbx

-From MAILER-DAEMON Fri Jan  2 17:38:11 2009
+From MAILER-DAEMON Sat Jan  3 10:07:33 2009
 Delivered-To: foobar@gmail.com
 Received: by 10.114.108.3 with SMTP id g3cs509927wac;
         Mon, 29 Dec 2008 17:13:30 -0800 (PST)
 Mercurial-devel mailing list
 Mercurial-devel@selenic.com
 http://selenic.com/mailman/listinfo/mercurial-devel
-
-From MAILER-DAEMON Fri Jan  2 17:38:11 2009
+From MAILER-DAEMON Sat Jan  3 10:07:33 2009
 Delivered-To: foobar@gmail.com
 Received: by 10.114.108.3 with SMTP id g3cs509927wac;
         Mon, 29 Dec 2008 17:13:30 -0800 (PST)
 Mercurial-devel mailing list
 Mercurial-devel@selenic.com
 http://selenic.com/mailman/listinfo/mercurial-devel
-
-From MAILER-DAEMON Fri Jan  2 17:38:11 2009
+From MAILER-DAEMON Sat Jan  3 10:07:33 2009
 Delivered-To: foobar@gmail.com
 Received: by 10.114.108.3 with SMTP id g3cs509927wac;
         Mon, 29 Dec 2008 17:13:30 -0800 (PST)
 _______________________________________________
 Mercurial-devel mailing list
 Mercurial-devel@selenic.com
-http://selenic.com/mailman/listinfo/mercurial-devel
+http://selenic.com/mailman/listinfo/mercurial-devel