sobjects/test/unittest_notification.py
branch3.5
changeset 2920 64322aa83a1d
parent 2650 18aec79ec3a3
child 2968 0e3460341023
child 4212 ab6573088b4a
--- a/sobjects/test/unittest_notification.py	Thu Aug 20 17:33:05 2009 +0200
+++ b/sobjects/test/unittest_notification.py	Thu Aug 20 17:44:27 2009 +0200
@@ -9,9 +9,9 @@
 from socket import gethostname
 
 from logilab.common.testlib import unittest_main, TestCase
-from cubicweb.devtools.apptest import EnvBasedTC
+from cubicweb.devtools.apptest import EnvBasedTC, MAILBOX
 
-from cubicweb.sobjects.notification import construct_message_id, parse_message_id
+from cubicweb.common.mail import construct_message_id, parse_message_id
 
 class MessageIdTC(TestCase):
     def test_base(self):
@@ -71,16 +71,14 @@
 
     def test_status_change_view(self):
         req = self.session()
-        u = self.create_user('toto', req=req)
-        assert u.req
-        assert u.rset
-        self.execute('SET X in_state S WHERE X eid %s, S name "deactivated"' % u.eid)
-        v = self.vreg['views'].select('notif_status_change', req, rset=u.rset, row=0)
-        content = v.render(row=0, comment='yeah',
-                           previous_state='activated',
-                           current_state='deactivated')
-        # remove date
-        self.assertEquals(content,
+        u = self.create_user('toto', req=req)#, commit=False) XXX in cw 3.6, and remove set_pool
+        req.set_pool()
+        u.fire_transition('deactivate', comment=u'yeah')
+        self.failIf(MAILBOX)
+        self.commit()
+        self.assertEquals(len(MAILBOX), 1)
+        email = MAILBOX[0]
+        self.assertEquals(email.content,
                           '''
 admin changed status from <activated> to <deactivated> for entity
 'toto'
@@ -89,7 +87,7 @@
 
 url: http://testing.fr/cubicweb/cwuser/toto
 ''')
-        self.assertEquals(v.subject(), 'status changed cwuser #%s (admin)' % u.eid)
+        self.assertEquals(email.subject, 'status changed cwuser #%s (admin)' % u.eid)
 
 if __name__ == '__main__':
     unittest_main()