|
@@ -10,6 +10,7 @@ import transaction
|
10
|
10
|
|
11
|
11
|
from tracim.config.app_cfg import CFG
|
12
|
12
|
from tracim.lib.notifications import DummyNotifier
|
|
13
|
+from tracim.lib.notifications import EmailNotifier
|
13
|
14
|
from tracim.lib.notifications import EST
|
14
|
15
|
from tracim.lib.notifications import NotifierFactory
|
15
|
16
|
from tracim.lib.notifications import RealNotifier
|
|
@@ -47,3 +48,51 @@ class TestDummyNotifier(TestStandard):
|
47
|
48
|
ok_('{workspace_label}' in tags)
|
48
|
49
|
ok_('{content_label}' in tags)
|
49
|
50
|
ok_('{content_status_label}' in tags)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+class TestEmailNotifier(TestStandard):
|
|
54
|
+ def test_email_notifier__build_name_with_user_id(self):
|
|
55
|
+ u = User()
|
|
56
|
+ u.user_id = 3
|
|
57
|
+ u.display_name = 'François Michâlié'
|
|
58
|
+
|
|
59
|
+ config = CFG.get_instance()
|
|
60
|
+ config.EMAIL_NOTIFICATION_FROM_EMAIL = 'noreply+{user_id}@tracim.io'
|
|
61
|
+
|
|
62
|
+ notifier = EmailNotifier(smtp_config=None, global_config=config)
|
|
63
|
+ email = notifier._get_sender(user=u)
|
|
64
|
+ eq_('=?utf-8?q?Fran=C3=A7ois_Mich=C3=A2li=C3=A9_via_Tracim?= <noreply+3@tracim.io>', email) # nopep8
|
|
65
|
+
|
|
66
|
+ def test_email_notifier__build_name_without_user_id(self):
|
|
67
|
+ u = User()
|
|
68
|
+ u.user_id = 3
|
|
69
|
+ u.display_name = 'François Michâlié'
|
|
70
|
+
|
|
71
|
+ config = CFG.get_instance()
|
|
72
|
+ config.EMAIL_NOTIFICATION_FROM_EMAIL = 'noreply@tracim.io'
|
|
73
|
+
|
|
74
|
+ notifier = EmailNotifier(smtp_config=None, global_config=config)
|
|
75
|
+ email = notifier._get_sender(user=u)
|
|
76
|
+ eq_('=?utf-8?q?Fran=C3=A7ois_Mich=C3=A2li=C3=A9_via_Tracim?= <noreply@tracim.io>', email) # nopep8
|
|
77
|
+
|
|
78
|
+ def test_email_notifier__build_name_with_user_id_wrong_syntax(self):
|
|
79
|
+ u = User()
|
|
80
|
+ u.user_id = 3
|
|
81
|
+ u.display_name = 'François Michâlié'
|
|
82
|
+
|
|
83
|
+ config = CFG.get_instance()
|
|
84
|
+ config.EMAIL_NOTIFICATION_FROM_EMAIL = 'noreply+{userid}@tracim.io'
|
|
85
|
+
|
|
86
|
+ notifier = EmailNotifier(smtp_config=None, global_config=config)
|
|
87
|
+ email = notifier._get_sender(user=u)
|
|
88
|
+ eq_('=?utf-8?q?Fran=C3=A7ois_Mich=C3=A2li=C3=A9_via_Tracim?= <noreply+{userid}@tracim.io>', email) # nopep8
|
|
89
|
+
|
|
90
|
+ def test_email_notifier__build_name_with_no_user(self):
|
|
91
|
+ config = CFG.get_instance()
|
|
92
|
+ config.EMAIL_NOTIFICATION_FROM_DEFAULT_LABEL = 'Robot'
|
|
93
|
+ config.EMAIL_NOTIFICATION_FROM_EMAIL = 'noreply@tracim.io'
|
|
94
|
+
|
|
95
|
+ notifier = EmailNotifier(smtp_config=None, global_config=config)
|
|
96
|
+ email = notifier._get_sender()
|
|
97
|
+ eq_('Robot <noreply@tracim.io>', email)
|
|
98
|
+
|