Back to index

plone3  3.1.7
Public Member Functions
plone.app.contentrules.tests.test_action_mail.TestMailAction Class Reference
Inheritance diagram for plone.app.contentrules.tests.test_action_mail.TestMailAction:
Inheritance graph
[legend]
Collaboration diagram for plone.app.contentrules.tests.test_action_mail.TestMailAction:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def afterSetUp
def testRegistered
def testInvokeAddView
def testInvokeEditView
def testExecute
def testExecuteNoSource
def testExecuteMultiRecipients

Detailed Description

Definition at line 33 of file test_action_mail.py.


Member Function Documentation

Definition at line 35 of file test_action_mail.py.

00035 
00036     def afterSetUp(self):
00037         self.setRoles(('Manager',))
00038         self.portal.invokeFactory('Folder', 'target')
00039         self.folder.invokeFactory('Document', 'd1',
00040             title=unicode('Wälkommen', 'utf-8'))

Here is the call graph for this function:

Definition at line 78 of file test_action_mail.py.

00078 
00079     def testExecute(self):
00080         self.loginAsPortalOwner()
00081         sm = getSiteManager(self.portal)
00082         sm.unregisterUtility(provided=IMailHost)
00083         dummyMailHost = DummySecureMailHost('dMailhost')
00084         sm.registerUtility(dummyMailHost, IMailHost)
00085         e = MailAction()
00086         e.source = "foo@bar.be"
00087         e.recipients = "bar@foo.be"
00088         e.message = u"Päge '${title}' created in ${url} !"
00089         ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)),
00090                              IExecutable)
00091         ex()
00092         self.failUnless(isinstance(dummyMailHost.sent[0], MIMEText))
00093         mailSent = dummyMailHost.sent[0]
00094         self.assertEqual('text/plain; charset="utf-8"',
00095                         mailSent.get('Content-Type'))
00096         self.assertEqual("bar@foo.be", mailSent.get('To'))
00097         self.assertEqual("foo@bar.be", mailSent.get('From'))
00098         self.assertEqual("P\xc3\xa4ge 'W\xc3\xa4lkommen' created in \
00099 http://nohost/plone/Members/test_user_1_/d1 !",
00100                          mailSent.get_payload(decode=True))

Here is the call graph for this function:

Definition at line 126 of file test_action_mail.py.

00126 
00127     def testExecuteMultiRecipients(self):
00128         self.loginAsPortalOwner()
00129         sm = getSiteManager(self.portal)
00130         sm.unregisterUtility(provided=IMailHost)
00131         dummyMailHost = DummySecureMailHost('dMailhost')
00132         sm.registerUtility(dummyMailHost, IMailHost)
00133         e = MailAction()
00134         e.source = 'foo@bar.be'
00135         e.recipients = 'bar@foo.be,foo@bar.be'
00136         e.message = 'Document created !'
00137         ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)),
00138                              IExecutable)
00139         ex()
00140         self.assertEqual(len(dummyMailHost.sent), 2)
00141         self.failUnless(isinstance(dummyMailHost.sent[0], MIMEText))
00142         mailSent = dummyMailHost.sent[0]
00143         self.assertEqual('text/plain; charset="utf-8"',
00144                         mailSent.get('Content-Type'))
00145         self.assertEqual('bar@foo.be', mailSent.get('To'))
00146         self.assertEqual('foo@bar.be', mailSent.get('From'))
00147         self.assertEqual('Document created !',mailSent.get_payload(decode=True))
00148         mailSent = dummyMailHost.sent[1]
00149         self.assertEqual('text/plain; charset="utf-8"',
00150                         mailSent.get('Content-Type'))
00151         self.assertEqual('foo@bar.be', mailSent.get('To'))
00152         self.assertEqual('foo@bar.be', mailSent.get('From'))
00153         self.assertEqual('Document created !',mailSent.get_payload(decode=True))

Here is the call graph for this function:

Definition at line 101 of file test_action_mail.py.

00101 
00102     def testExecuteNoSource(self):
00103         self.loginAsPortalOwner()
00104         sm = getSiteManager(self.portal)
00105         sm.unregisterUtility(provided=IMailHost)
00106         dummyMailHost = DummySecureMailHost('dMailhost')
00107         sm.registerUtility(dummyMailHost, IMailHost)
00108         e = MailAction()
00109         e.recipients = 'bar@foo.be,foo@bar.be'
00110         e.message = 'Document created !'
00111         ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)),
00112                              IExecutable)
00113         self.assertRaises(ValueError, ex)
00114         # if we provide a site mail address this won't fail anymore
00115         sm.manage_changeProperties({'email_from_address': 'manager@portal.be'})
00116         ex()
00117         self.failUnless(isinstance(dummyMailHost.sent[0], MIMEText))
00118         mailSent = dummyMailHost.sent[0]
00119         self.assertEqual('text/plain; charset="utf-8"',
00120                         mailSent.get('Content-Type'))
00121         self.assertEqual("bar@foo.be", mailSent.get('To'))
00122         self.assertEqual("Site Administrator <manager@portal.be>",
00123                          mailSent.get('From'))
00124         self.assertEqual("Document created !",
00125                          mailSent.get_payload(decode=True))

Here is the call graph for this function:

Definition at line 48 of file test_action_mail.py.

00048 
00049     def testInvokeAddView(self):
00050         element = getUtility(IRuleAction, name='plone.actions.Mail')
00051         storage = getUtility(IRuleStorage)
00052         storage[u'foo'] = Rule()
00053         rule = self.portal.restrictedTraverse('++rule++foo')
00054 
00055         adding = getMultiAdapter((rule, self.portal.REQUEST), name='+action')
00056         addview = getMultiAdapter((adding, self.portal.REQUEST),
00057                                   name=element.addview)
00058         self.failUnless(isinstance(addview,MailAddForm))
00059 
00060         addview.createAndAdd(data={'subject' : 'My Subject',
00061                                    'source': 'foo@bar.be',
00062                                    'recipients': 'foo@bar.be,bar@foo.be',
00063                                    'message': 'Hey, Oh!'})
00064 
00065         e = rule.actions[0]
00066         self.failUnless(isinstance(e, MailAction))
00067         self.assertEquals('My Subject', e.subject)
00068         self.assertEquals('foo@bar.be', e.source)
00069         self.assertEquals('foo@bar.be,bar@foo.be', e.recipients)
00070         self.assertEquals('Hey, Oh!', e.message)

Definition at line 71 of file test_action_mail.py.

00071 
00072     def testInvokeEditView(self):
00073         element = getUtility(IRuleAction, name='plone.actions.Mail')
00074         e = MailAction()
00075         editview = getMultiAdapter((e, self.folder.REQUEST),
00076                                    name=element.editview)
00077         self.failUnless(isinstance(editview, MailEditForm))

Definition at line 41 of file test_action_mail.py.

00041 
00042     def testRegistered(self):
00043         element = getUtility(IRuleAction, name='plone.actions.Mail')
00044         self.assertEquals('plone.actions.Mail', element.addview)
00045         self.assertEquals('edit', element.editview)
00046         self.assertEquals(None, element.for_)
00047         self.assertEquals(IObjectEvent, element.event)


The documentation for this class was generated from the following file: