Skip to content
Snippets Groups Projects
Commit 465f38875f92 authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

test update and fix

parent 5ebb8152c714
No related branches found
No related tags found
No related merge requests found
......@@ -2,7 +2,7 @@
import re
from logilab.common.testlib import unittest_main, mock_object
from cubicweb.devtools.testlib import CubicWebTC
from cubicweb.devtools.testlib import CubicWebTC, MAILBOX
from email.Header import decode_header
from cubicweb.sobjects.notification import RenderAndSendNotificationView
......@@ -13,6 +13,7 @@
"""test blog specific behaviours"""
def test_notifications(self):
cubicweb_blog = self.request().create_entity('Blog', title=u'cubicweb', description=u"cubicweb c'est beau")
blog_entry_1 = self.request().create_entity('BlogEntry', title=u"hop", content=u"cubicweb hop")
req = self.request()
cubicweb_blog = req.create_entity('Blog', title=u'cubicweb', description=u"cubicweb c'est beau")
blog_entry_1 = req.create_entity('BlogEntry', title=u"hop", content=u"cubicweb hop")
self.execute('SET E entry_of B WHERE B eid %(beid)s, E eid %(eeid)s' % {'beid' :cubicweb_blog.eid, 'eeid' : blog_entry_1.eid})
......@@ -18,3 +19,3 @@
self.execute('SET E entry_of B WHERE B eid %(beid)s, E eid %(eeid)s' % {'beid' :cubicweb_blog.eid, 'eeid' : blog_entry_1.eid})
blog_entry_2 = self.request().create_entity('BlogEntry', title=u"yes", content=u"cubicweb yes")
blog_entry_2 = req.create_entity('BlogEntry', title=u"yes", content=u"cubicweb yes")
self.execute('SET E entry_of B WHERE B eid %(beid)s, E eid %(eeid)s' % {'beid' :cubicweb_blog.eid, 'eeid' : blog_entry_2.eid})
......@@ -20,14 +21,11 @@
self.execute('SET E entry_of B WHERE B eid %(beid)s, E eid %(eeid)s' % {'beid' :cubicweb_blog.eid, 'eeid' : blog_entry_2.eid})
session = self.session
for op in session.pending_operations:
if isinstance(op, RenderAndSendNotificationView):
op.precommit_event()
sendmailops = [op for op in session.pending_operations if isinstance(op, SendMailOp)]
self.assertEquals(len(sendmailops), 1)
sendmailop = sendmailops[0]
sent = [re.sub('#\d+', '#EID', decode_header(msg['subject'].encode())[0][0])
for msg, recipients in op.to_send]
self.assertListEquals(sent, ['[data] hop', '[data] yes'])
self.assertEquals(len(MAILBOX), 0)
self.commit()
self.assertEquals(len(MAILBOX), 2)
mail = MAILBOX[0]
self.assertEquals(mail.subject, '[data] hop')
mail = MAILBOX[1]
self.assertEquals(mail.subject, '[data] yes')
if __name__ == '__main__':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment