--- a/sobjects/test/unittest_notification.py Tue Aug 18 09:25:44 2009 +0200
+++ b/sobjects/test/unittest_notification.py Fri Aug 21 16:26:20 2009 +0200
@@ -9,9 +9,9 @@
from socket import gethostname
from logilab.common.testlib import unittest_main, TestCase
-from cubicweb.devtools.testlib import CubicWebTC
+from cubicweb.devtools.testlib import CubicWebTC, 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):
@@ -70,17 +70,14 @@
class StatusChangeViewsTC(CubicWebTC):
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,
+ req = self.session()
+ u = self.create_user('toto', req=req, commit=False)
+ 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 +86,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()