author | Denis Laxalde <denis.laxalde@logilab.fr> |
Fri, 14 Apr 2017 15:40:49 +0200 | |
changeset 12164 | 8d1a7021c817 |
parent 11129 | 97095348b3ee |
permissions | -rw-r--r-- |
0 | 1 |
# -*- coding: utf-8 -*- |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
2 |
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
3 |
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
4 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
5 |
# This file is part of CubicWeb. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
6 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
7 |
# CubicWeb is free software: you can redistribute it and/or modify it under the |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
8 |
# terms of the GNU Lesser General Public License as published by the Free |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
9 |
# Software Foundation, either version 2.1 of the License, or (at your option) |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
10 |
# any later version. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
11 |
# |
5424
8ecbcbff9777
replace logilab-common by CubicWeb in disclaimer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5421
diff
changeset
|
12 |
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
13 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
14 |
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
15 |
# details. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
16 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
17 |
# You should have received a copy of the GNU Lesser General Public License along |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
18 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
11083
4b18b1027d02
[test] Gather tests about mail module
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10907
diff
changeset
|
19 |
"""unit tests for module cubicweb.mail""" |
0 | 20 |
|
21 |
import os |
|
10326
03d98646d57c
[mail] include Date header in generated mails (closes #5271058)
Julien Cristau <julien.cristau@logilab.fr>
parents:
9149
diff
changeset
|
22 |
import re |
11083
4b18b1027d02
[test] Gather tests about mail module
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10907
diff
changeset
|
23 |
from socket import gethostname |
3153 | 24 |
import sys |
11083
4b18b1027d02
[test] Gather tests about mail module
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10907
diff
changeset
|
25 |
from unittest import TestCase |
0 | 26 |
|
27 |
from logilab.common.umessage import message_from_string |
|
28 |
||
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
29 |
from cubicweb.devtools.testlib import CubicWebTC |
11083
4b18b1027d02
[test] Gather tests about mail module
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10907
diff
changeset
|
30 |
from cubicweb.mail import format_mail, construct_message_id, parse_message_id |
0 | 31 |
|
32 |
||
33 |
def getlogin(): |
|
9149
31ed9dd946d1
[test] typo
Dimitri Papadopoulos <dimitri.papadopoulos@cea.fr>
parents:
6340
diff
changeset
|
34 |
"""avoid using os.getlogin() because of strange tty / stdin problems |
0 | 35 |
(man 3 getlogin) |
36 |
Another solution would be to use $LOGNAME, $USER or $USERNAME |
|
37 |
""" |
|
3153 | 38 |
if sys.platform != 'win32': |
39 |
import pwd |
|
40 |
return pwd.getpwuid(os.getuid())[0] |
|
41 |
else: |
|
42 |
return os.environ.get('USERNAME') |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
43 |
|
0 | 44 |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
45 |
class EmailTC(CubicWebTC): |
0 | 46 |
|
47 |
def test_format_mail(self): |
|
48 |
self.set_option('sender-addr', 'bim@boum.fr') |
|
49 |
self.set_option('sender-name', 'BimBam') |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
50 |
|
0 | 51 |
mail = format_mail({'name': 'oim', 'email': 'oim@logilab.fr'}, |
52 |
['test@logilab.fr'], u'un petit cöucou', u'bïjour', |
|
53 |
config=self.config) |
|
10326
03d98646d57c
[mail] include Date header in generated mails (closes #5271058)
Julien Cristau <julien.cristau@logilab.fr>
parents:
9149
diff
changeset
|
54 |
result = mail.as_string() |
03d98646d57c
[mail] include Date header in generated mails (closes #5271058)
Julien Cristau <julien.cristau@logilab.fr>
parents:
9149
diff
changeset
|
55 |
result = re.sub('^Date: .*$', 'Date: now', result, flags=re.MULTILINE) |
03d98646d57c
[mail] include Date header in generated mails (closes #5271058)
Julien Cristau <julien.cristau@logilab.fr>
parents:
9149
diff
changeset
|
56 |
self.assertMultiLineEqual(result, """\ |
0 | 57 |
MIME-Version: 1.0 |
58 |
Content-Type: text/plain; charset="utf-8" |
|
59 |
Content-Transfer-Encoding: base64 |
|
60 |
Subject: =?utf-8?q?b=C3=AFjour?= |
|
61 |
From: =?utf-8?q?oim?= <oim@logilab.fr> |
|
62 |
Reply-to: =?utf-8?q?oim?= <oim@logilab.fr>, =?utf-8?q?BimBam?= <bim@boum.fr> |
|
63 |
X-CW: data |
|
64 |
To: test@logilab.fr |
|
10326
03d98646d57c
[mail] include Date header in generated mails (closes #5271058)
Julien Cristau <julien.cristau@logilab.fr>
parents:
9149
diff
changeset
|
65 |
Date: now |
0 | 66 |
|
67 |
dW4gcGV0aXQgY8O2dWNvdQ== |
|
68 |
""") |
|
69 |
msg = message_from_string(mail.as_string()) |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
70 |
self.assertEqual(msg.get('subject'), u'bïjour') |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
71 |
self.assertEqual(msg.get('from'), u'oim <oim@logilab.fr>') |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
72 |
self.assertEqual(msg.get('to'), u'test@logilab.fr') |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
73 |
self.assertEqual(msg.get('reply-to'), u'oim <oim@logilab.fr>, BimBam <bim@boum.fr>') |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
74 |
self.assertEqual(msg.get_payload(decode=True), u'un petit cöucou') |
0 | 75 |
|
76 |
def test_format_mail_euro(self): |
|
77 |
mail = format_mail({'name': u'oîm', 'email': u'oim@logilab.fr'}, |
|
78 |
['test@logilab.fr'], u'un petit cöucou €', u'bïjour €') |
|
10326
03d98646d57c
[mail] include Date header in generated mails (closes #5271058)
Julien Cristau <julien.cristau@logilab.fr>
parents:
9149
diff
changeset
|
79 |
result = mail.as_string() |
03d98646d57c
[mail] include Date header in generated mails (closes #5271058)
Julien Cristau <julien.cristau@logilab.fr>
parents:
9149
diff
changeset
|
80 |
result = re.sub('^Date: .*$', 'Date: now', result, flags=re.MULTILINE) |
03d98646d57c
[mail] include Date header in generated mails (closes #5271058)
Julien Cristau <julien.cristau@logilab.fr>
parents:
9149
diff
changeset
|
81 |
self.assertMultiLineEqual(result, """\ |
0 | 82 |
MIME-Version: 1.0 |
83 |
Content-Type: text/plain; charset="utf-8" |
|
84 |
Content-Transfer-Encoding: base64 |
|
85 |
Subject: =?utf-8?b?YsOvam91ciDigqw=?= |
|
86 |
From: =?utf-8?q?o=C3=AEm?= <oim@logilab.fr> |
|
87 |
Reply-to: =?utf-8?q?o=C3=AEm?= <oim@logilab.fr> |
|
88 |
To: test@logilab.fr |
|
10326
03d98646d57c
[mail] include Date header in generated mails (closes #5271058)
Julien Cristau <julien.cristau@logilab.fr>
parents:
9149
diff
changeset
|
89 |
Date: now |
0 | 90 |
|
91 |
dW4gcGV0aXQgY8O2dWNvdSDigqw= |
|
92 |
""") |
|
93 |
msg = message_from_string(mail.as_string()) |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
94 |
self.assertEqual(msg.get('subject'), u'bïjour €') |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
95 |
self.assertEqual(msg.get('from'), u'oîm <oim@logilab.fr>') |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
96 |
self.assertEqual(msg.get('to'), u'test@logilab.fr') |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
97 |
self.assertEqual(msg.get('reply-to'), u'oîm <oim@logilab.fr>') |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
98 |
self.assertEqual(msg.get_payload(decode=True), u'un petit cöucou €') |
0 | 99 |
|
100 |
def test_format_mail_from_reply_to(self): |
|
101 |
# no sender-name, sender-addr in the configuration |
|
102 |
self.set_option('sender-name', '') |
|
103 |
self.set_option('sender-addr', '') |
|
104 |
msg = format_mail({'name': u'', 'email': u''}, |
|
105 |
['test@logilab.fr'], u'un petit cöucou €', u'bïjour €', |
|
106 |
config=self.config) |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
107 |
self.assertEqual(msg.get('from'), u'') |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
108 |
self.assertEqual(msg.get('reply-to'), None) |
0 | 109 |
msg = format_mail({'name': u'tutu', 'email': u'tutu@logilab.fr'}, |
110 |
['test@logilab.fr'], u'un petit cöucou €', u'bïjour €', |
|
111 |
config=self.config) |
|
112 |
msg = message_from_string(msg.as_string()) |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
113 |
self.assertEqual(msg.get('from'), u'tutu <tutu@logilab.fr>') |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
114 |
self.assertEqual(msg.get('reply-to'), u'tutu <tutu@logilab.fr>') |
0 | 115 |
msg = format_mail({'name': u'tutu', 'email': u'tutu@logilab.fr'}, |
116 |
['test@logilab.fr'], u'un petit cöucou €', u'bïjour €') |
|
117 |
msg = message_from_string(msg.as_string()) |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
118 |
self.assertEqual(msg.get('from'), u'tutu <tutu@logilab.fr>') |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
119 |
self.assertEqual(msg.get('reply-to'), u'tutu <tutu@logilab.fr>') |
0 | 120 |
# set sender name and address as expected |
121 |
self.set_option('sender-name', 'cubicweb-test') |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
122 |
self.set_option('sender-addr', 'cubicweb-test@logilab.fr') |
0 | 123 |
# anonymous notification: no name and no email specified |
124 |
msg = format_mail({'name': u'', 'email': u''}, |
|
11083
4b18b1027d02
[test] Gather tests about mail module
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10907
diff
changeset
|
125 |
['test@logilab.fr'], u'un petit cöucou €', u'bïjour €', |
4b18b1027d02
[test] Gather tests about mail module
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10907
diff
changeset
|
126 |
config=self.config) |
0 | 127 |
msg = message_from_string(msg.as_string()) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
128 |
self.assertEqual(msg.get('from'), u'cubicweb-test <cubicweb-test@logilab.fr>') |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
129 |
self.assertEqual(msg.get('reply-to'), u'cubicweb-test <cubicweb-test@logilab.fr>') |
0 | 130 |
# anonymous notification: only email specified |
131 |
msg = format_mail({'email': u'tutu@logilab.fr'}, |
|
11083
4b18b1027d02
[test] Gather tests about mail module
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10907
diff
changeset
|
132 |
['test@logilab.fr'], u'un petit cöucou €', u'bïjour €', |
4b18b1027d02
[test] Gather tests about mail module
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10907
diff
changeset
|
133 |
config=self.config) |
0 | 134 |
msg = message_from_string(msg.as_string()) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
135 |
self.assertEqual(msg.get('from'), u'cubicweb-test <tutu@logilab.fr>') |
11083
4b18b1027d02
[test] Gather tests about mail module
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10907
diff
changeset
|
136 |
self.assertEqual( |
4b18b1027d02
[test] Gather tests about mail module
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10907
diff
changeset
|
137 |
msg.get('reply-to'), |
4b18b1027d02
[test] Gather tests about mail module
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10907
diff
changeset
|
138 |
u'cubicweb-test <tutu@logilab.fr>, cubicweb-test <cubicweb-test@logilab.fr>') |
0 | 139 |
# anonymous notification: only name specified |
140 |
msg = format_mail({'name': u'tutu'}, |
|
141 |
['test@logilab.fr'], u'un petit cöucou €', u'bïjour €', |
|
142 |
config=self.config) |
|
143 |
msg = message_from_string(msg.as_string()) |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
144 |
self.assertEqual(msg.get('from'), u'tutu <cubicweb-test@logilab.fr>') |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
145 |
self.assertEqual(msg.get('reply-to'), u'tutu <cubicweb-test@logilab.fr>') |
0 | 146 |
|
147 |
||
11083
4b18b1027d02
[test] Gather tests about mail module
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10907
diff
changeset
|
148 |
class MessageIdTC(TestCase): |
4b18b1027d02
[test] Gather tests about mail module
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10907
diff
changeset
|
149 |
|
4b18b1027d02
[test] Gather tests about mail module
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10907
diff
changeset
|
150 |
def test_base(self): |
4b18b1027d02
[test] Gather tests about mail module
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10907
diff
changeset
|
151 |
msgid1 = construct_message_id('testapp', 21) |
4b18b1027d02
[test] Gather tests about mail module
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10907
diff
changeset
|
152 |
msgid2 = construct_message_id('testapp', 21) |
4b18b1027d02
[test] Gather tests about mail module
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10907
diff
changeset
|
153 |
self.assertNotEqual(msgid1, msgid2) |
4b18b1027d02
[test] Gather tests about mail module
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10907
diff
changeset
|
154 |
self.assertNotIn('&', msgid1) |
4b18b1027d02
[test] Gather tests about mail module
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10907
diff
changeset
|
155 |
self.assertNotIn('=', msgid1) |
4b18b1027d02
[test] Gather tests about mail module
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10907
diff
changeset
|
156 |
self.assertNotIn('/', msgid1) |
4b18b1027d02
[test] Gather tests about mail module
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10907
diff
changeset
|
157 |
self.assertNotIn('+', msgid1) |
4b18b1027d02
[test] Gather tests about mail module
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10907
diff
changeset
|
158 |
values = parse_message_id(msgid1, 'testapp') |
4b18b1027d02
[test] Gather tests about mail module
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10907
diff
changeset
|
159 |
self.assertTrue(values) |
4b18b1027d02
[test] Gather tests about mail module
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10907
diff
changeset
|
160 |
# parse_message_id should work with or without surrounding <> |
4b18b1027d02
[test] Gather tests about mail module
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10907
diff
changeset
|
161 |
self.assertEqual(values, parse_message_id(msgid1[1:-1], 'testapp')) |
4b18b1027d02
[test] Gather tests about mail module
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10907
diff
changeset
|
162 |
self.assertEqual(values['eid'], '21') |
4b18b1027d02
[test] Gather tests about mail module
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10907
diff
changeset
|
163 |
self.assertIn('timestamp', values) |
4b18b1027d02
[test] Gather tests about mail module
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10907
diff
changeset
|
164 |
self.assertEqual(parse_message_id(msgid1[1:-1], 'anotherapp'), None) |
4b18b1027d02
[test] Gather tests about mail module
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10907
diff
changeset
|
165 |
|
4b18b1027d02
[test] Gather tests about mail module
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10907
diff
changeset
|
166 |
def test_notimestamp(self): |
4b18b1027d02
[test] Gather tests about mail module
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10907
diff
changeset
|
167 |
msgid1 = construct_message_id('testapp', 21, False) |
4b18b1027d02
[test] Gather tests about mail module
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10907
diff
changeset
|
168 |
construct_message_id('testapp', 21, False) |
4b18b1027d02
[test] Gather tests about mail module
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10907
diff
changeset
|
169 |
values = parse_message_id(msgid1, 'testapp') |
4b18b1027d02
[test] Gather tests about mail module
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10907
diff
changeset
|
170 |
self.assertEqual(values, {'eid': '21'}) |
4b18b1027d02
[test] Gather tests about mail module
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10907
diff
changeset
|
171 |
|
4b18b1027d02
[test] Gather tests about mail module
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10907
diff
changeset
|
172 |
def test_parse_message_doesnt_raise(self): |
4b18b1027d02
[test] Gather tests about mail module
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10907
diff
changeset
|
173 |
self.assertEqual(parse_message_id('oijioj@bla.bla', 'tesapp'), None) |
4b18b1027d02
[test] Gather tests about mail module
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10907
diff
changeset
|
174 |
self.assertEqual(parse_message_id('oijioj@bla', 'tesapp'), None) |
4b18b1027d02
[test] Gather tests about mail module
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10907
diff
changeset
|
175 |
self.assertEqual(parse_message_id('oijioj', 'tesapp'), None) |
4b18b1027d02
[test] Gather tests about mail module
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10907
diff
changeset
|
176 |
|
4b18b1027d02
[test] Gather tests about mail module
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10907
diff
changeset
|
177 |
def test_nonregr_empty_message_id(self): |
4b18b1027d02
[test] Gather tests about mail module
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10907
diff
changeset
|
178 |
for eid in (1, 12, 123, 1234): |
4b18b1027d02
[test] Gather tests about mail module
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10907
diff
changeset
|
179 |
msgid1 = construct_message_id('testapp', eid, 12) |
4b18b1027d02
[test] Gather tests about mail module
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10907
diff
changeset
|
180 |
self.assertNotEqual(msgid1, '<@testapp.%s>' % gethostname()) |
4b18b1027d02
[test] Gather tests about mail module
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10907
diff
changeset
|
181 |
|
0 | 182 |
|
183 |
if __name__ == '__main__': |
|
11083
4b18b1027d02
[test] Gather tests about mail module
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
10907
diff
changeset
|
184 |
from logilab.common.testlib import unittest_main |
0 | 185 |
unittest_main() |