61 self.assertNotEqual(msgid1, '<@testapp.%s>' % gethostname()) |
59 self.assertNotEqual(msgid1, '<@testapp.%s>' % gethostname()) |
62 |
60 |
63 class NotificationTC(CubicWebTC): |
61 class NotificationTC(CubicWebTC): |
64 |
62 |
65 def test_recipients_finder(self): |
63 def test_recipients_finder(self): |
66 urset = self.execute('CWUser X WHERE X login "admin"') |
64 with self.admin_access.web_request() as req: |
67 self.execute('INSERT EmailAddress X: X address "admin@logilab.fr", U primary_email X ' |
65 urset = req.execute('CWUser X WHERE X login "admin"') |
68 'WHERE U eid %(x)s', {'x': urset[0][0]}) |
66 req.execute('INSERT EmailAddress X: X address "admin@logilab.fr", U primary_email X ' |
69 self.execute('INSERT CWProperty X: X pkey "ui.language", X value "fr", X for_user U ' |
67 'WHERE U eid %(x)s', {'x': urset[0][0]}) |
70 'WHERE U eid %(x)s', {'x': urset[0][0]}) |
68 req.execute('INSERT CWProperty X: X pkey "ui.language", X value "fr", X for_user U ' |
71 self.commit() # commit so that admin get its properties updated |
69 'WHERE U eid %(x)s', {'x': urset[0][0]}) |
72 finder = self.vreg['components'].select('recipients_finder', |
70 req.cnx.commit() # commit so that admin get its properties updated |
73 self.request(), rset=urset) |
71 finder = self.vreg['components'].select('recipients_finder', |
74 self.set_option('default-recipients-mode', 'none') |
72 req, rset=urset) |
75 self.assertEqual(finder.recipients(), []) |
73 self.set_option('default-recipients-mode', 'none') |
76 self.set_option('default-recipients-mode', 'users') |
74 self.assertEqual(finder.recipients(), []) |
77 self.assertEqual(finder.recipients(), [(u'admin@logilab.fr', 'fr')]) |
75 self.set_option('default-recipients-mode', 'users') |
78 self.set_option('default-recipients-mode', 'default-dest-addrs') |
76 self.assertEqual(finder.recipients(), [(u'admin@logilab.fr', 'fr')]) |
79 self.set_option('default-dest-addrs', 'abcd@logilab.fr, efgh@logilab.fr') |
77 self.set_option('default-recipients-mode', 'default-dest-addrs') |
80 self.assertEqual(finder.recipients(), [('abcd@logilab.fr', 'en'), ('efgh@logilab.fr', 'en')]) |
78 self.set_option('default-dest-addrs', 'abcd@logilab.fr, efgh@logilab.fr') |
|
79 self.assertEqual(finder.recipients(), [('abcd@logilab.fr', 'en'), ('efgh@logilab.fr', 'en')]) |
81 |
80 |
82 def test_status_change_view(self): |
81 def test_status_change_view(self): |
83 req = self.request() |
82 with self.admin_access.web_request() as req: |
84 u = self.create_user(req, 'toto') |
83 u = self.create_user(req, 'toto') |
85 iwfable = u.cw_adapt_to('IWorkflowable') |
84 iwfable = u.cw_adapt_to('IWorkflowable') |
86 iwfable.fire_transition('deactivate', comment=u'yeah') |
85 iwfable.fire_transition('deactivate', comment=u'yeah') |
87 self.assertFalse(MAILBOX) |
86 self.assertFalse(MAILBOX) |
88 self.commit() |
87 req.cnx.commit() |
89 self.assertEqual(len(MAILBOX), 1) |
88 self.assertEqual(len(MAILBOX), 1) |
90 email = MAILBOX[0] |
89 email = MAILBOX[0] |
91 self.assertEqual(email.content, |
90 self.assertEqual(email.content, |
92 ''' |
91 ''' |
93 admin changed status from <activated> to <deactivated> for entity |
92 admin changed status from <activated> to <deactivated> for entity |
94 'toto' |
93 'toto' |
95 |
94 |
96 yeah |
95 yeah |
97 |
96 |
98 url: http://testing.fr/cubicweb/cwuser/toto |
97 url: http://testing.fr/cubicweb/cwuser/toto |
99 ''') |
98 ''') |
100 self.assertEqual(email.subject, |
99 self.assertEqual(email.subject, |
101 'status changed CWUser #%s (admin)' % u.eid) |
100 'status changed CWUser #%s (admin)' % u.eid) |
102 |
101 |
103 if __name__ == '__main__': |
102 if __name__ == '__main__': |
104 unittest_main() |
103 unittest_main() |