update test suite to compare mime-decoded messages
authorAndrew Engelbrecht <sudoman@ninthfloor.org>
Mon, 20 Jul 2015 19:27:18 +0000 (15:27 -0400)
committerAndrew Engelbrecht <sudoman@ninthfloor.org>
Mon, 7 Dec 2015 18:26:42 +0000 (13:26 -0500)
run-tests
tests/flatten-mime [new file with mode: 0755]
tests/out1.txt

index 5cbdb2720d9bb66b88d1b633c0f347c91c6e80e2..48570f1299c7bce9429552f557e39fe901a7b397 100755 (executable)
--- a/run-tests
+++ b/run-tests
 
 G_HOME=./tests/testgnupghome
 
-OUT_DIFF_1="$(./edward < ./tests/test1.eml | GNUPGHOME="$G_HOME" gpg 2> /dev/null | diff -Z -u ./tests/out1.txt - )"
+OUT_DIFF_1="$(time ./edward < ./tests/test1.eml | GNUPGHOME="$G_HOME" gpg 2> /dev/null | ./tests/flatten-mime | diff -Z -u ./tests/out1.txt - )"
 
 if [ -n "$OUT_DIFF_1" ] ; then
     echo "*** test 1 failed! difference:" >&2
     echo "$OUT_DIFF_1" >&2
 fi
 
-
diff --git a/tests/flatten-mime b/tests/flatten-mime
new file mode 100755 (executable)
index 0000000..9406eae
--- /dev/null
@@ -0,0 +1,38 @@
+#! /usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+"""***********************************************************************
+* "flatten-mime" is free software: you can redistribute it and/or modify *
+* it under the terms of the GNU Affero Public License as published by    *
+* the Free Software Foundation, either version 3 of the License, or      *
+* (at your option) any later version.                                    *
+*                                                                        *
+* "flatten-mime" is distributed in the hope that it will be useful,      *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of         *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
+* GNU Affero Public License for more details.                            *
+*                                                                        *
+* You should have received a copy of the GNU Affero Public License       *
+* along with Edward.  If not, see <http://www.gnu.org/licenses/>.        *
+*                                                                        *
+* Copyright (C) 2015 Andrew Engelbrecht                     (AGPLv3+)    *
+**************************************************************************
+
+"""
+
+import sys
+import email.parser
+
+
+mime_text = sys.stdin.read()
+
+email_struct = email.parser.Parser().parsestr(mime_text)
+
+for subpart in email_struct.walk():
+    payload_b = subpart.get_payload(decode=True)
+
+    if payload_b:
+        payload = payload_b.decode("utf-8")
+
+        print(payload)
+
index 265c9d274efc4c34c879532bbd14e48a49d5ae4f..6a7350b1a38599e04651f3f0ff4da7c7585e01e3 100644 (file)
@@ -1,23 +1,18 @@
-MIME-Version: 1.0
-Content-Type: text/plain; charset="utf-8"
-Content-Transfer-Encoding: quoted-printable
-
 thanks for the message!
 
 
 > thanks for the message!
->=20
-> > =C3=9Cber Spa=C3=9F.
-> >=20
-> > qual =C3=A8 il suono di una mano sola?
-> >=20
-> > =E3=81=93=E3=82=93=E3=81=AB=E3=81=A1=E3=81=AF=E3=80=81=E3=81=8A=E5=85=
-=83=E6=B0=97=E3=81=A7=E3=81=99=E3=81=8B=EF=BC=9F
-> >=20
->=20
+> 
+> > Über Spaß.
+> > 
+> > qual è il suono di una mano sola?
+> > 
+> > こんにちは、お元気ですか?
+> > 
+> 
 > test.
->=20
+> 
 > -andrew
->=20
->=20
->=20
+> 
+> 
+>