This repository has been archived by the owner on Dec 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathtest_Direct_Basic.py
79 lines (68 loc) · 3.54 KB
/
test_Direct_Basic.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
from email.header import Header
from email.mime.multipart import MIMEMultipart
import os
from tests import BaseTestClasses
class Direct_Basic(BaseTestClasses.Email2PDFTestCase):
def setUp(self):
super(Direct_Basic, self).setUp()
self.msg = MIMEMultipart()
def test_simple(self):
self.addHeaders()
error = self.invokeDirectly()
self.assertTrue(self.existsByTime())
self.assertEqual('', error)
self.assertFalse(self.existsByTimeWarning())
self.assertFalse(self.existsByTimeOriginal())
def test_missing_from_to(self):
path = os.path.join(self.examineDir, "missing_from_to.pdf")
self.addHeaders(frm=None, to=None)
error = self.invokeDirectly(outputFile=path, extraParams=['--headers'])
self.assertTrue(os.path.exists(path))
self.assertEqual('', error)
self.assertFalse(self.existsByTimeWarning())
self.assertFalse(self.existsByTimeOriginal())
def test_internationalised_subject(self):
path = os.path.join(self.examineDir, "internationalised_subject.pdf")
self.addHeaders(subject=bytes("Hello!", 'iso-8859-1'), subject_encoding='iso-8859-1')
error = self.invokeDirectly(outputFile=path, extraParams=['--headers'])
self.assertTrue(os.path.exists(path))
self.assertEqual('', error)
self.assertFalse(self.existsByTimeWarning())
self.assertFalse(self.existsByTimeOriginal())
def test_internationalised_subject2(self):
path = os.path.join(self.examineDir, "internationalised_subject_jp.pdf")
self.addHeaders(subject='=?iso-2022-jp?B?GyRCOiNHLyRiSSwkOiRkJGo/ayQyJGsbKEIhIRskQkcvS3ZBMCRO?=')
error = self.invokeDirectly(outputFile=path, extraParams=['--headers'])
self.assertTrue(os.path.exists(path))
self.assertEqual('', error)
self.assertFalse(self.existsByTimeWarning())
self.assertFalse(self.existsByTimeOriginal())
def test_internationalised_subject3(self):
path = os.path.join(self.examineDir, "internationalised_subject_de.pdf")
self.addHeaders(subject='Ihre Anfrage, Giesestra=?utf-8?B?w58=?=e 5')
error = self.invokeDirectly(outputFile=path, extraParams=['--headers'])
self.assertTrue(os.path.exists(path))
self.assertEqual('', error)
self.assertFalse(self.existsByTimeWarning())
self.assertFalse(self.existsByTimeOriginal())
def test_internationalised_subject4(self):
path = os.path.join(self.examineDir, "internationalised_subject_complex.pdf")
header = Header()
header.append(bytes('£100', 'iso-8859-1'), 'iso-8859-1')
header.append(bytes(' is != how much ', 'utf-8'), 'utf-8')
header.append(bytes('I have to spend!', 'iso-8859-15'), 'iso-8859-15')
self.addHeaders(subject=header.encode())
error = self.invokeDirectly(outputFile=path, extraParams=['--headers'])
self.assertTrue(os.path.exists(path))
self.assertEqual('', error)
self.assertFalse(self.existsByTimeWarning())
self.assertFalse(self.existsByTimeOriginal())
def test_contains_left_angle_bracket_mime(self):
path = os.path.join(self.examineDir, "left_angle_bracket_mime.pdf")
self.attachText("<angle bracket test>")
error = self.invokeDirectly(outputFile=path)
self.assertTrue(os.path.exists(path))
self.assertEqual('', error)
self.assertRegex(self.getPDFText(path), "<angle bracket test>")
self.assertFalse(self.existsByTimeWarning())
self.assertFalse(self.existsByTimeOriginal())