|
@@ -53,6 +53,16 @@ class TestHtmlMailQuoteChecker(TestStandard):
|
53
|
53
|
main_elem = soup.find()
|
54
|
54
|
assert HtmlMailQuoteChecker._is_gmail_quote(main_elem) is False
|
55
|
55
|
|
|
56
|
+ def test_unit__is_outlook_com_quote_ok(self):
|
|
57
|
+ soup = BeautifulSoup('<div id="divRplyFwdMsg"></div>', 'html.parser')
|
|
58
|
+ main_elem = soup.find()
|
|
59
|
+ assert HtmlMailQuoteChecker._is_outlook_com_quote(main_elem) is True
|
|
60
|
+
|
|
61
|
+ def test_unit__is_outlook_com_quote_no(self):
|
|
62
|
+ soup = BeautifulSoup('<div id="Signature"></div>', 'html.parser')
|
|
63
|
+ main_elem = soup.find()
|
|
64
|
+ assert HtmlMailQuoteChecker._is_outlook_com_quote(main_elem) is False
|
|
65
|
+
|
56
|
66
|
# TODO - G.M - 2017-11-24 - Check Yahoo and New roundcube html mail with
|
57
|
67
|
# correct mail example
|
58
|
68
|
|
|
@@ -96,6 +106,18 @@ class TestHtmlMailSignatureChecker(TestStandard):
|
96
|
106
|
main_elem = soup.find()
|
97
|
107
|
assert HtmlMailSignatureChecker._is_gmail_signature(main_elem) is True
|
98
|
108
|
|
|
109
|
+ def test_unit__is_outlook_com_signature_no(self):
|
|
110
|
+ soup = BeautifulSoup('<div id="divRplyFwdMsg"></div>', 'html.parser')
|
|
111
|
+ main_elem = soup.find()
|
|
112
|
+ assert HtmlMailSignatureChecker._is_outlook_com_signature(main_elem) \
|
|
113
|
+ is False
|
|
114
|
+
|
|
115
|
+ def test_unit__is_outlook_com_signature_ok(self):
|
|
116
|
+ soup = BeautifulSoup('<div id="Signature"></div>', 'html.parser')
|
|
117
|
+ main_elem = soup.find()
|
|
118
|
+ assert HtmlMailSignatureChecker._is_outlook_com_signature(main_elem) \
|
|
119
|
+ is True
|
|
120
|
+
|
99
|
121
|
class TestBodyMailsParts(TestStandard):
|
100
|
122
|
|
101
|
123
|
def test_unit__std_list_methods(self):
|
|
@@ -138,60 +160,6 @@ class TestBodyMailsParts(TestStandard):
|
138
|
160
|
a = BodyMailPart('a', BodyMailPartType.Main)
|
139
|
161
|
mail_parts._check_value(a)
|
140
|
162
|
|
141
|
|
- @raises(SignatureIndexError)
|
142
|
|
- def test_unit__check_sign_last_elem_check_main_after_sign(self):
|
143
|
|
- mail_parts = BodyMailParts()
|
144
|
|
- a = BodyMailPart('a', BodyMailPartType.Main)
|
145
|
|
- mail_parts._list.append(a)
|
146
|
|
- b = BodyMailPart('b', BodyMailPartType.Signature)
|
147
|
|
- mail_parts._list.append(b)
|
148
|
|
- c = BodyMailPart('c', BodyMailPartType.Main)
|
149
|
|
- mail_parts._check_sign_last_elem(c)
|
150
|
|
-
|
151
|
|
- def test_unit__check_sign_last_elem_check_sign_after_sign(self):
|
152
|
|
- mail_parts = BodyMailParts()
|
153
|
|
- a = BodyMailPart('a', BodyMailPartType.Main)
|
154
|
|
- mail_parts._list.append(a)
|
155
|
|
- b = BodyMailPart('b', BodyMailPartType.Signature)
|
156
|
|
- mail_parts._list.append(b)
|
157
|
|
- c = BodyMailPart('c', BodyMailPartType.Signature)
|
158
|
|
- mail_parts._check_sign_last_elem(c)
|
159
|
|
-
|
160
|
|
- def test_unit__disable_signature_no_sign(self):
|
161
|
|
- mail_parts = BodyMailParts()
|
162
|
|
- a = BodyMailPart('a', BodyMailPartType.Main)
|
163
|
|
- mail_parts._list.append(a)
|
164
|
|
- b = BodyMailPart('b', BodyMailPartType.Quote)
|
165
|
|
- mail_parts._list.append(b)
|
166
|
|
- mail_parts.disable_signature()
|
167
|
|
- assert mail_parts[1] == b
|
168
|
|
-
|
169
|
|
- def test_unit__disable_signature_sign_quote_as_previous_elem(self):
|
170
|
|
- mail_parts = BodyMailParts()
|
171
|
|
- a = BodyMailPart('a', BodyMailPartType.Main)
|
172
|
|
- mail_parts._list.append(a)
|
173
|
|
- b = BodyMailPart('b', BodyMailPartType.Quote)
|
174
|
|
- mail_parts._list.append(b)
|
175
|
|
- c = BodyMailPart('c', BodyMailPartType.Signature)
|
176
|
|
- mail_parts._list.append(c)
|
177
|
|
- mail_parts.disable_signature()
|
178
|
|
- assert len(mail_parts) == 3
|
179
|
|
- assert mail_parts[2].text == 'c'
|
180
|
|
- assert mail_parts[2].part_type == BodyMailPartType.Main
|
181
|
|
-
|
182
|
|
- def test_unit__disable_signature_sign_main_as_previous_elem(self):
|
183
|
|
- mail_parts = BodyMailParts()
|
184
|
|
- a = BodyMailPart('a', BodyMailPartType.Quote)
|
185
|
|
- mail_parts._list.append(a)
|
186
|
|
- b = BodyMailPart('b', BodyMailPartType.Main)
|
187
|
|
- mail_parts._list.append(b)
|
188
|
|
- c = BodyMailPart('c', BodyMailPartType.Signature)
|
189
|
|
- mail_parts._list.append(c)
|
190
|
|
- mail_parts.disable_signature()
|
191
|
|
- assert len(mail_parts) == 2
|
192
|
|
- assert mail_parts[1].text == 'bc'
|
193
|
|
- assert mail_parts[1].part_type == BodyMailPartType.Main
|
194
|
|
-
|
195
|
163
|
def test_unit__drop_part_type(self):
|
196
|
164
|
mail_parts = BodyMailParts()
|
197
|
165
|
a = BodyMailPart('a', BodyMailPartType.Main)
|
|
@@ -251,13 +219,14 @@ class TestBodyMailsParts(TestStandard):
|
251
|
219
|
|
252
|
220
|
class TestParsedMail(TestStandard):
|
253
|
221
|
|
254
|
|
- def test_other__check_gmail_mail(self):
|
|
222
|
+ def test_other__check_gmail_mail_text_only(self):
|
255
|
223
|
text_only = '''<div dir="ltr">Voici le texte<br></div>'''
|
256
|
224
|
mail = ParsedHTMLMail(text_only)
|
257
|
225
|
elements = mail.get_elements()
|
258
|
226
|
assert len(elements) == 1
|
259
|
227
|
assert elements[0].part_type == BodyMailPartType.Main
|
260
|
228
|
|
|
229
|
+ def test_other__check_gmail_mail_text_signature(self):
|
261
|
230
|
text_and_signature = '''
|
262
|
231
|
<div dir="ltr">POF<br clear="all"><div><br>-- <br>
|
263
|
232
|
<div class="gmail_signature" data-smartmail="gmail_signature">
|
|
@@ -273,6 +242,7 @@ class TestParsedMail(TestStandard):
|
273
|
242
|
assert elements[0].part_type == BodyMailPartType.Main
|
274
|
243
|
assert elements[1].part_type == BodyMailPartType.Signature
|
275
|
244
|
|
|
245
|
+ def test_other__check_gmail_mail_text_quote(self):
|
276
|
246
|
text_and_quote = '''
|
277
|
247
|
<div dir="ltr">Réponse<br>
|
278
|
248
|
<div class="gmail_extra"><br>
|
|
@@ -301,6 +271,7 @@ class TestParsedMail(TestStandard):
|
301
|
271
|
assert elements[0].part_type == BodyMailPartType.Main
|
302
|
272
|
assert elements[1].part_type == BodyMailPartType.Quote
|
303
|
273
|
|
|
274
|
+ def test_other__check_gmail_mail_text_quote_text(self):
|
304
|
275
|
text_quote_text = '''
|
305
|
276
|
<div dir="ltr">Avant<br>
|
306
|
277
|
<div class="gmail_extra"><br>
|
|
@@ -338,7 +309,7 @@ class TestParsedMail(TestStandard):
|
338
|
309
|
assert elements[1].part_type == BodyMailPartType.Quote
|
339
|
310
|
assert elements[2].part_type == BodyMailPartType.Main
|
340
|
311
|
|
341
|
|
-
|
|
312
|
+ def test_other__check_gmail_mail_text_quote_signature(self):
|
342
|
313
|
text_quote_signature = '''
|
343
|
314
|
<div dir="ltr">Hey !<br>
|
344
|
315
|
</div>
|
|
@@ -390,6 +361,7 @@ class TestParsedMail(TestStandard):
|
390
|
361
|
assert elements[0].part_type == BodyMailPartType.Main
|
391
|
362
|
assert elements[1].part_type == BodyMailPartType.Quote
|
392
|
363
|
|
|
364
|
+ def test_other__check_gmail_mail_text_quote_text_signature(self):
|
393
|
365
|
text_quote_text_sign = '''
|
394
|
366
|
<div dir="ltr">Test<br>
|
395
|
367
|
<div class="gmail_extra"><br>
|
|
@@ -442,7 +414,7 @@ class TestParsedMail(TestStandard):
|
442
|
414
|
assert elements[2].part_type == BodyMailPartType.Main
|
443
|
415
|
assert elements[3].part_type == BodyMailPartType.Signature
|
444
|
416
|
|
445
|
|
- def test_other__check_thunderbird_mail(self):
|
|
417
|
+ def test_other__check_thunderbird_mail_text_only(self):
|
446
|
418
|
|
447
|
419
|
text_only = '''Coucou<br><br><br>'''
|
448
|
420
|
mail = ParsedHTMLMail(text_only)
|
|
@@ -450,6 +422,7 @@ class TestParsedMail(TestStandard):
|
450
|
422
|
assert len(elements) == 1
|
451
|
423
|
assert elements[0].part_type == BodyMailPartType.Main
|
452
|
424
|
|
|
425
|
+ def test_other__check_thunderbird_mail_text_signature(self):
|
453
|
426
|
text_and_signature = '''
|
454
|
427
|
<p>Test<br>
|
455
|
428
|
</p>
|
|
@@ -462,6 +435,7 @@ class TestParsedMail(TestStandard):
|
462
|
435
|
assert elements[0].part_type == BodyMailPartType.Main
|
463
|
436
|
assert elements[1].part_type == BodyMailPartType.Signature
|
464
|
437
|
|
|
438
|
+ def test_other__check_thunderbird_mail_text_quote(self):
|
465
|
439
|
text_and_quote = '''
|
466
|
440
|
<p>Pof<br>
|
467
|
441
|
</p>
|
|
@@ -486,6 +460,7 @@ class TestParsedMail(TestStandard):
|
486
|
460
|
assert elements[0].part_type == BodyMailPartType.Main
|
487
|
461
|
assert elements[1].part_type == BodyMailPartType.Quote
|
488
|
462
|
|
|
463
|
+ def test_other__check_thunderbird_mail_text_quote_text(self):
|
489
|
464
|
text_quote_text = '''
|
490
|
465
|
<p>Pof<br>
|
491
|
466
|
</p>
|
|
@@ -523,6 +498,7 @@ class TestParsedMail(TestStandard):
|
523
|
498
|
assert elements[1].part_type == BodyMailPartType.Quote
|
524
|
499
|
assert elements[2].part_type == BodyMailPartType.Main
|
525
|
500
|
|
|
501
|
+ def test_other__check_thunderbird_mail_text_quote_signature(self):
|
526
|
502
|
text_quote_signature = '''
|
527
|
503
|
<p>Coucou<br>
|
528
|
504
|
</p>
|
|
@@ -554,6 +530,7 @@ class TestParsedMail(TestStandard):
|
554
|
530
|
assert elements[1].part_type == BodyMailPartType.Quote
|
555
|
531
|
assert elements[2].part_type == BodyMailPartType.Signature
|
556
|
532
|
|
|
533
|
+ def test_other__check_thunderbird_mail_text_quote_text_signature(self):
|
557
|
534
|
text_quote_text_sign = '''
|
558
|
535
|
<p>Avant<br>
|
559
|
536
|
</p>
|
|
@@ -579,4 +556,168 @@ class TestParsedMail(TestStandard):
|
579
|
556
|
assert elements[2].part_type == BodyMailPartType.Main
|
580
|
557
|
assert elements[3].part_type == BodyMailPartType.Signature
|
581
|
558
|
|
|
559
|
+ # INFO - G.M - 2017-11-28 - Test for outlook.com webapp html mail
|
|
560
|
+ # outlook.com ui doesn't seems to allow complex reply, new message
|
|
561
|
+ # and signature are always before quoted one.
|
|
562
|
+
|
|
563
|
+ def test_other__check_outlook_com_mail_text_only(self):
|
|
564
|
+
|
|
565
|
+ text_only = '''
|
|
566
|
+ <div id="divtagdefaultwrapper"
|
|
567
|
+ style="font-size:12pt;color:#000000;
|
|
568
|
+ font-family:Calibri,Helvetica,sans-serif;"
|
|
569
|
+ dir="ltr">
|
|
570
|
+ <p style="margin-top:0;margin-bottom:0">message<br>
|
|
571
|
+ </p>
|
|
572
|
+ </div>
|
|
573
|
+ '''
|
|
574
|
+ mail = ParsedHTMLMail(text_only)
|
|
575
|
+ elements = mail.get_elements()
|
|
576
|
+ assert len(elements) == 1
|
|
577
|
+ assert elements[0].part_type == BodyMailPartType.Main
|
|
578
|
+
|
|
579
|
+ def test_other__check_outlook_com_mail_text_signature(self):
|
|
580
|
+ text_and_signature = '''
|
|
581
|
+ <div id="divtagdefaultwrapper"
|
|
582
|
+ style="font-size:12pt;color:#000000;
|
|
583
|
+ font-family:Calibri,Helvetica,sans-serif;"
|
|
584
|
+ dir="ltr">
|
|
585
|
+ <p style="margin-top:0;margin-bottom:0">Test<br>
|
|
586
|
+ </p>
|
|
587
|
+ <p style="margin-top:0;margin-bottom:0"><br>
|
|
588
|
+ </p>
|
|
589
|
+ <div id="Signature">
|
|
590
|
+ <div id="divtagdefaultwrapper" style="font-size: 12pt; color:
|
|
591
|
+ rgb(0, 0, 0); background-color: rgb(255, 255, 255);
|
|
592
|
+ font-family:
|
|
593
|
+ Calibri,Arial,Helvetica,sans-serif,"EmojiFont","Apple
|
|
594
|
+ Color Emoji","Segoe UI
|
|
595
|
+ Emoji",NotoColorEmoji,"Segoe UI
|
|
596
|
+ Symbol","Android Emoji",EmojiSymbols;">
|
|
597
|
+ Envoyé à partir de <a href="http://aka.ms/weboutlook"
|
|
598
|
+ id="LPNoLP">Outlook</a></div>
|
|
599
|
+ </div>
|
|
600
|
+ </div>
|
|
601
|
+ '''
|
|
602
|
+ mail = ParsedHTMLMail(text_and_signature)
|
|
603
|
+ elements = mail.get_elements()
|
|
604
|
+ assert len(elements) == 2
|
|
605
|
+ assert elements[0].part_type == BodyMailPartType.Main
|
|
606
|
+ assert elements[1].part_type == BodyMailPartType.Signature
|
|
607
|
+
|
|
608
|
+ def test_other__check_outlook_com_mail_text_quote(self):
|
|
609
|
+ text_and_quote = '''
|
|
610
|
+ <div id="divtagdefaultwrapper"
|
|
611
|
+ style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;"
|
|
612
|
+ dir="ltr">
|
|
613
|
+ <p style="margin-top:0;margin-bottom:0">Salut !<br>
|
|
614
|
+ </p>
|
|
615
|
+ </div>
|
|
616
|
+ <hr style="display:inline-block;width:98%" tabindex="-1">
|
|
617
|
+ <div id="divRplyFwdMsg" dir="ltr"><font style="font-size:11pt"
|
|
618
|
+ color="#000000" face="Calibri, sans-serif"><b>De :</b> John Doe<br>
|
|
619
|
+ <b>Envoyé :</b> mardi 28 novembre 2017 12:44:59<br>
|
|
620
|
+ <b>À :</b> dev.bidule@localhost.fr<br>
|
|
621
|
+ <b>Objet :</b> voila</font>
|
|
622
|
+ <div> </div>
|
|
623
|
+ </div>
|
|
624
|
+ <style type="text/css" style="display:none">
|
|
625
|
+ <!--
|
|
626
|
+ p
|
|
627
|
+ 	{margin-top:0;
|
|
628
|
+ 	margin-bottom:0}
|
|
629
|
+ -->
|
|
630
|
+ </style>
|
|
631
|
+ <div dir="ltr">
|
|
632
|
+ <div id="x_divtagdefaultwrapper" dir="ltr" style="font-size:12pt;
|
|
633
|
+ color:#000000; font-family:Calibri,Helvetica,sans-serif">
|
|
634
|
+ Contenu
|
|
635
|
+ <p style="margin-top:0; margin-bottom:0"><br>
|
|
636
|
+ </p>
|
|
637
|
+ <div id="x_Signature">
|
|
638
|
+ <div id="x_divtagdefaultwrapper" dir="ltr"
|
|
639
|
+ style="font-size:12pt; color:rgb(0,0,0);
|
|
640
|
+ background-color:rgb(255,255,255);
|
|
641
|
+ font-family:Calibri,Arial,Helvetica,sans-serif,"EmojiFont","Apple
|
|
642
|
+ Color Emoji","Segoe UI
|
|
643
|
+ Emoji",NotoColorEmoji,"Segoe UI
|
|
644
|
+ Symbol","Android Emoji",EmojiSymbols">
|
|
645
|
+ DLMQDNLQNDMLQS<br>
|
|
646
|
+ qs<br>
|
|
647
|
+ dqsd<br>
|
|
648
|
+ d<br>
|
|
649
|
+ qsd<br>
|
|
650
|
+ </div>
|
|
651
|
+ </div>
|
|
652
|
+ </div>
|
|
653
|
+ </div>
|
|
654
|
+ '''
|
|
655
|
+ mail = ParsedHTMLMail(text_and_quote)
|
|
656
|
+ elements = mail.get_elements()
|
|
657
|
+ assert len(elements) == 2
|
|
658
|
+ assert elements[0].part_type == BodyMailPartType.Main
|
|
659
|
+ assert elements[1].part_type == BodyMailPartType.Quote
|
|
660
|
+
|
|
661
|
+ def test_other__check_outlook_com_mail_text_signature_quote(self):
|
|
662
|
+ text_signature_quote = '''
|
|
663
|
+ <div id="divtagdefaultwrapper"
|
|
664
|
+ style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;"
|
|
665
|
+ dir="ltr">
|
|
666
|
+ <p style="margin-top:0;margin-bottom:0">Salut !<br>
|
|
667
|
+ </p>
|
|
668
|
+ <p style="margin-top:0;margin-bottom:0"><br>
|
|
669
|
+ </p>
|
|
670
|
+ <div id="Signature">
|
|
671
|
+ <div id="divtagdefaultwrapper" dir="ltr" style="font-size: 12pt;
|
|
672
|
+ color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);
|
|
673
|
+ font-family:
|
|
674
|
+ Calibri,Arial,Helvetica,sans-serif,"EmojiFont","Apple
|
|
675
|
+ Color Emoji","Segoe UI
|
|
676
|
+ Emoji",NotoColorEmoji,"Segoe UI
|
|
677
|
+ Symbol","Android Emoji",EmojiSymbols;">
|
|
678
|
+ Envoyée depuis Outlook<br>
|
|
679
|
+ </div>
|
|
680
|
+ </div>
|
|
681
|
+ </div>
|
|
682
|
+ <hr style="display:inline-block;width:98%" tabindex="-1">
|
|
683
|
+ <div id="divRplyFwdMsg" dir="ltr"><font style="font-size:11pt"
|
|
684
|
+ color="#000000" face="Calibri, sans-serif"><b>De :</b> John Doe
|
|
685
|
+ <dev.bidule@localhost.fr><br>
|
|
686
|
+ <b>Envoyé :</b> mardi 28 novembre 2017 12:51:42<br>
|
|
687
|
+ <b>À :</b> John Doe<br>
|
|
688
|
+ <b>Objet :</b> Re: Test</font>
|
|
689
|
+ <div> </div>
|
|
690
|
+ </div>
|
|
691
|
+ <div style="background-color:#FFFFFF">
|
|
692
|
+ <p>Coucou<br>
|
|
693
|
+ </p>
|
|
694
|
+ <br>
|
|
695
|
+ <div class="x_moz-cite-prefix">Le 28/11/2017 à 12:39, John Doe a
|
|
696
|
+ écrit :<br>
|
|
697
|
+ </div>
|
|
698
|
+ <blockquote type="cite">
|
|
699
|
+ <div id="x_divtagdefaultwrapper" dir="ltr">
|
|
700
|
+ <p>Test<br>
|
|
701
|
+ </p>
|
|
702
|
+ <p><br>
|
|
703
|
+ </p>
|
|
704
|
+ <div id="x_Signature">
|
|
705
|
+ <div id="x_divtagdefaultwrapper">Envoyé à partir de <a
|
|
706
|
+ href="http://aka.ms/weboutlook" id="LPNoLP">
|
|
707
|
+ Outlook</a></div>
|
|
708
|
+ </div>
|
|
709
|
+ </div>
|
|
710
|
+ </blockquote>
|
|
711
|
+ <br>
|
|
712
|
+ <div class="x_moz-signature">-- <br>
|
|
713
|
+ TEST DE signature</div>
|
|
714
|
+ </div>
|
|
715
|
+ '''
|
|
716
|
+
|
|
717
|
+ mail = ParsedHTMLMail(text_signature_quote)
|
|
718
|
+ elements = mail.get_elements()
|
|
719
|
+ assert len(elements) == 3
|
|
720
|
+ assert elements[0].part_type == BodyMailPartType.Main
|
|
721
|
+ assert elements[1].part_type == BodyMailPartType.Signature
|
|
722
|
+ assert elements[2].part_type == BodyMailPartType.Quote
|
582
|
723
|
|