def testExecuteMultiGroupsAndUsers(self):
        self.loginAsPortalOwner()
        sm = getSiteManager(self.portal)
        sm.unregisterUtility(provided=IMailHost)

        dummyMailHost = DummyMailHost('dMailhost')
        sm.registerUtility(dummyMailHost, IMailHost)

        e = MailGroupAction()
        e.source = "*****@*****.**"
        e.groups = ['group1', 'group2']
        e.members = ['portal_owner', default_user, ]
        e.message = 'Document created !'
        ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)),
                             IExecutable)
        ex()

        self.assertEqual(len(dummyMailHost.sent[0]['mto']), 4)
        self.failUnless(isinstance(dummyMailHost.sent[0]['msg'], Message))

        mailSent = dummyMailHost.sent[0]['msg']
        mailTo = dummyMailHost.sent[0]['mto']
        mailFrom = dummyMailHost.sent[0]['mfrom']
        self.assertTrue(mailSent.get('Content-Type').startswith('multipart/related'))

        self.assertEqual('*****@*****.**', mailFrom)
        self.assertIn('*****@*****.**', mailTo)
        self.assertIn('*****@*****.**', mailTo)
        self.assertIn('*****@*****.**', mailTo)
        self.assertIn('*****@*****.**', mailTo)
        self.assertIn('Document created !', str(mailSent))
    def testExecuteMultiGroupsAndUsers(self):
        setRoles(self.portal, TEST_USER_ID, ['Manager'])
        dummyMailHost = self._setup_mockmail()

        e = MailGroupAction()
        e.source = '*****@*****.**'
        e.groups = ['group1', 'group2']
        e.members = [SITE_OWNER_NAME, default_user]
        e.message = 'Document created !'
        ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)),
                             IExecutable)
        ex()

        mailSent = message_from_string(dummyMailHost.messages[0]['msg'])
        mailTo = dummyMailHost.messages[0]['mto']
        mailFrom = mailSent.get('From')
        mailType = mailSent.get('Content-Type')
        self.assertEqual(len(mailTo), 4)
        self.assertTrue(isinstance(mailSent, Message))
        self.assertTrue(mailType.startswith('multipart/related'))

        self.assertEqual('*****@*****.**', mailFrom)
        self.assertIn('*****@*****.**', mailTo)
        self.assertIn('*****@*****.**', mailTo)
        self.assertIn('*****@*****.**', mailTo)
        self.assertIn('*****@*****.**', mailTo)
        self.assertIn('Document created !', str(mailSent))
    def testExecuteNoSource(self):
        self.loginAsPortalOwner()
        sm = getSiteManager(self.portal)
        sm.unregisterUtility(provided=IMailHost)
        dummyMailHost = DummyMailHost('dMailhost')
        sm.registerUtility(dummyMailHost, IMailHost)
        e = MailGroupAction()
        e.groups = ['group1', ]
        e.message = 'Document created !'
        ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)),
                             IExecutable)
        self.assertRaises(ValueError, ex)
        # if we provide a site mail address this won't fail anymore
        sm.manage_changeProperties({'email_from_address': '*****@*****.**'})
        ex()
        self.failUnless(isinstance(dummyMailHost.sent[0]['msg'], Message))

        mailSent = dummyMailHost.sent[0]['msg']
        mailTo = dummyMailHost.sent[0]['mto']
        mailFrom = dummyMailHost.sent[0]['mfrom']

        self.assertTrue(mailSent.get('Content-Type').startswith('multipart/related'))
        self.assertIn("*****@*****.**", mailTo)
        self.assertIn("*****@*****.**", mailFrom)
        self.assertIn('Document created !', str(mailSent))
Beispiel #4
0
    def testExecuteMultiGroupsAndUsers(self):
        setRoles(self.portal, TEST_USER_ID, ['Manager'])
        dummyMailHost = self._setup_mockmail()

        e = MailGroupAction()
        e.source = '*****@*****.**'
        e.groups = ['group1', 'group2']
        e.members = [
            SITE_OWNER_NAME,
            default_user,
        ]
        e.message = 'Document created !'
        ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)),
                             IExecutable)
        ex()

        mailSent = message_from_string(dummyMailHost.messages[0]['msg'])
        mailTo = dummyMailHost.messages[0]['mto']
        mailFrom = mailSent.get('From')
        mailType = mailSent.get('Content-Type')
        self.assertEqual(len(mailTo), 4)
        self.assertTrue(isinstance(mailSent, Message))
        self.assertTrue(mailType.startswith('multipart/related'))

        self.assertEqual('*****@*****.**', mailFrom)
        self.assertIn('*****@*****.**', mailTo)
        self.assertIn('*****@*****.**', mailTo)
        self.assertIn('*****@*****.**', mailTo)
        self.assertIn('*****@*****.**', mailTo)
        self.assertIn('Document created !', str(mailSent))
    def testExecuteNoSource(self):
        self.loginAsPortalOwner()
        sm = getSiteManager(self.portal)
        sm.unregisterUtility(provided=IMailHost)
        dummyMailHost = DummyMailHost('dMailhost')
        sm.registerUtility(dummyMailHost, IMailHost)
        e = MailGroupAction()
        e.groups = [
            'group1',
        ]
        e.message = 'Document created !'
        ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)),
                             IExecutable)
        self.assertRaises(ValueError, ex)
        # if we provide a site mail address this won't fail anymore
        sm.manage_changeProperties({'email_from_address': '*****@*****.**'})
        ex()
        self.failUnless(isinstance(dummyMailHost.sent[0]['msg'], Message))

        mailSent = dummyMailHost.sent[0]['msg']
        mailTo = dummyMailHost.sent[0]['mto']
        mailFrom = dummyMailHost.sent[0]['mfrom']

        self.assertTrue(
            mailSent.get('Content-Type').startswith('multipart/related'))
        self.assertIn("*****@*****.**", mailTo)
        self.assertIn("*****@*****.**", mailFrom)
        self.assertIn('Document created !', str(mailSent))
    def testExecuteMultiGroupsAndUsers(self):
        self.loginAsPortalOwner()
        sm = getSiteManager(self.portal)
        sm.unregisterUtility(provided=IMailHost)

        dummyMailHost = DummyMailHost('dMailhost')
        sm.registerUtility(dummyMailHost, IMailHost)

        e = MailGroupAction()
        e.source = "*****@*****.**"
        e.groups = ['group1', 'group2']
        e.members = [
            'portal_owner',
            default_user,
        ]
        e.message = 'Document created !'
        ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)),
                             IExecutable)
        ex()

        self.assertEqual(len(dummyMailHost.sent[0]['mto']), 4)
        self.failUnless(isinstance(dummyMailHost.sent[0]['msg'], Message))

        mailSent = dummyMailHost.sent[0]['msg']
        mailTo = dummyMailHost.sent[0]['mto']
        mailFrom = dummyMailHost.sent[0]['mfrom']
        self.assertTrue(
            mailSent.get('Content-Type').startswith('multipart/related'))

        self.assertEqual('*****@*****.**', mailFrom)
        self.assertIn('*****@*****.**', mailTo)
        self.assertIn('*****@*****.**', mailTo)
        self.assertIn('*****@*****.**', mailTo)
        self.assertIn('*****@*****.**', mailTo)
        self.assertIn('Document created !', str(mailSent))
    def testExecuteEmptyGroup(self):
        setRoles(self.portal, TEST_USER_ID, ['Manager'])
        dummyMailHost = self._setup_mockmail()

        e = MailGroupAction()
        e.source = '*****@*****.**'
        e.groups = ['group3']
        e.members = []
        e.message = 'Document created !'
        ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)),
                             IExecutable)
        ret = ex()

        self.assertFalse(ret)

        self.assertEqual(len(dummyMailHost.messages), 0)
Beispiel #8
0
    def testExecuteEmptyGroup(self):
        setRoles(self.portal, TEST_USER_ID, ['Manager'])
        dummyMailHost = self._setup_mockmail()

        e = MailGroupAction()
        e.source = '*****@*****.**'
        e.groups = ['group3']
        e.members = []
        e.message = 'Document created !'
        ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)),
                             IExecutable)
        ret = ex()

        self.assertFalse(ret)

        self.assertEqual(len(dummyMailHost.messages), 0)
 def testExecute(self):
     setRoles(self.portal, TEST_USER_ID, ['Manager'])
     dummyMailHost = self._setup_mockmail()
     e = MailGroupAction()
     e.source = '*****@*****.**'
     e.groups = ['group1']
     e.message = u'Päge \'${title}\' created in ${url} !'
     ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)),
                          IExecutable)
     ex()
     mailSent = message_from_string(dummyMailHost.messages[0]['msg'])
     mailTo = dummyMailHost.messages[0]['mto'][0]
     mailType = mailSent.get('Content-Type')
     self.assertTrue(mailType.startswith('multipart/related'))
     self.assertEqual('*****@*****.**', mailTo)
     self.assertEqual('*****@*****.**', mailSent.get('From'))
     self.assertIn('P=C3=A4ge \'W=C3=A4lkommen\' created in http://nohost/plone/Members/test_user=\n_1_/d1',
                   mailSent.get_payload(0).as_string())
 def testExecute(self):
     setRoles(self.portal, TEST_USER_ID, ['Manager'])
     dummyMailHost = self._setup_mockmail()
     e = MailGroupAction()
     e.source = '*****@*****.**'
     e.groups = ['group1']
     e.message = u'Päge \'${title}\' created in ${url} !'
     ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)),
                          IExecutable)
     ex()
     mailSent = message_from_string(dummyMailHost.messages[0]['msg'])
     mailTo = dummyMailHost.messages[0]['mto'][0]
     mailType = mailSent.get('Content-Type')
     self.assertTrue(mailType.startswith('multipart/related'))
     self.assertEqual('*****@*****.**', mailTo)
     self.assertEqual('*****@*****.**', mailSent.get('From'))
     self.assertIn(
         'P=C3=A4ge \'W=C3=A4lkommen\' created in http://nohost/plone/Members/test_user=\n_1_/d1',
         mailSent.get_payload(0).as_string())
 def testExecute(self):
     self.loginAsPortalOwner()
     sm = getSiteManager(self.portal)
     sm.unregisterUtility(provided=IMailHost)
     dummyMailHost = DummyMailHost('dMailhost')
     sm.registerUtility(dummyMailHost, IMailHost)
     e = MailGroupAction()
     e.source = "*****@*****.**"
     e.groups = ['group1', ]
     e.message = u"Päge '${title}' created in ${url} !"
     ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)),
                          IExecutable)
     ex()
     self.failUnless(isinstance(dummyMailHost.sent[0]['msg'], Message))
     mailSent = dummyMailHost.sent[0]['msg']
     self.assertTrue(mailSent.get('Content-Type').startswith('multipart/related'))
     self.assertEqual(None, mailSent.get('To'))
     self.assertEqual("*****@*****.**", mailSent.get('From'))
     self.assertIn("P=C3=A4ge \'W=C3=A4lkommen\' created in http://nohost/plone/Members/test_user=\n_1_/d1",
         str(mailSent.get_payload()[0]))
Beispiel #12
0
    def testExecuteNoSource(self):
        setRoles(self.portal, TEST_USER_ID, ['Manager'])
        dummyMailHost = self._setup_mockmail()

        e = MailGroupAction()
        e.groups = [
            'group1',
        ]
        e.message = 'Document created !'
        ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)),
                             IExecutable)
        if IS_PLONE_5:
            ret = ex()
            self.assertFalse(ret)
        else:
            self.assertRaises(ValueError, ex)

        # if we provide a site mail address this won't fail anymore
        if IS_PLONE_5:
            from plone.registry.interfaces import IRegistry
            from Products.CMFPlone.interfaces import IMailSchema
            registry = getUtility(IRegistry)
            mail_settings = registry.forInterface(IMailSchema, prefix='plone')

            mail_settings.email_from_address = '*****@*****.**'
            mail_settings.email_from_name = u'manager'
        else:
            sm = getSiteManager(self.portal)
            sm.manage_changeProperties(
                {'email_from_address': '*****@*****.**'})

        ret = ex()

        mailSent = message_from_string(dummyMailHost.messages[0]['msg'])
        mailTo = dummyMailHost.messages[0]['mto'][0]
        mailFrom = mailSent.get('From')
        mailType = mailSent.get('Content-Type')
        self.assertTrue(mailType.startswith('multipart/related'))
        self.assertIn('*****@*****.**', mailTo)
        self.assertIn('*****@*****.**', mailFrom)
        self.assertIn('Document created !', str(mailSent))
 def testExecuteMultiGroupsAndUsers(self):
     self.loginAsPortalOwner()
     sm = getSiteManager(self.portal)
     sm.unregisterUtility(provided=IMailHost)
     dummyMailHost = DummySecureMailHost('dMailhost')
     sm.registerUtility(dummyMailHost, IMailHost)
     e = MailGroupAction()
     e.source = "*****@*****.**"
     e.groups = ['group1', 'group2']
     e.members = ['portal_owner', default_user, ]
     e.message = 'Document created !'
     ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)),
                          IExecutable)
     ex()
     self.assertEqual(len(dummyMailHost.sent), 4)
     self.failUnless(isinstance(dummyMailHost.sent[0], MIMEText))
     mailSent = dummyMailHost.sent[0]
     self.assertEqual('text/plain; charset="utf-8"',
                     mailSent.get('Content-Type'))
     self.assertEqual('*****@*****.**', mailSent.get('To'))
     self.assertEqual('*****@*****.**', mailSent.get('From'))
     self.assertEqual('Document created !', mailSent.get_payload(decode=True))
     mailSent = dummyMailHost.sent[1]
     self.assertEqual('text/plain; charset="utf-8"',
                     mailSent.get('Content-Type'))
     self.assertEqual('*****@*****.**', mailSent.get('To'))
     self.assertEqual('*****@*****.**', mailSent.get('From'))
     self.assertEqual('Document created !', mailSent.get_payload(decode=True))
     mailSent = dummyMailHost.sent[2]
     self.assertEqual('text/plain; charset="utf-8"',
                     mailSent.get('Content-Type'))
     self.assertEqual('*****@*****.**', mailSent.get('To'))
     self.assertEqual('*****@*****.**', mailSent.get('From'))
     self.assertEqual('Document created !', mailSent.get_payload(decode=True))
     mailSent = dummyMailHost.sent[3]
     self.assertEqual('text/plain; charset="utf-8"',
                     mailSent.get('Content-Type'))
     self.assertEqual('*****@*****.**', mailSent.get('To'))
     self.assertEqual('*****@*****.**', mailSent.get('From'))
     self.assertEqual('Document created !', mailSent.get_payload(decode=True))
    def testExecute(self):
        self.loginAsPortalOwner()
        sm = getSiteManager(self.portal)
        sm.unregisterUtility(provided=IMailHost)
        dummyMailHost = DummySecureMailHost('dMailhost')
        sm.registerUtility(dummyMailHost, IMailHost)
        e = MailGroupAction()
        e.source = "*****@*****.**"
        e.groups = ['group1', ]
        e.message = u"Päge '${title}' created in ${url} !"
        ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)),
                             IExecutable)
        ex()
        self.failUnless(isinstance(dummyMailHost.sent[0], MIMEText))
        mailSent = dummyMailHost.sent[0]
        self.assertEqual('text/plain; charset="utf-8"',
                        mailSent.get('Content-Type'))
        self.assertEqual("*****@*****.**", mailSent.get('To'))
        self.assertEqual("*****@*****.**", mailSent.get('From'))
        self.assertEqual("P\xc3\xa4ge 'W\xc3\xa4lkommen' created in \
http://nohost/plone/Members/test_user_1_/d1 !",
                         mailSent.get_payload(decode=True))
    def testExecuteNoSource(self):
        setRoles(self.portal, TEST_USER_ID, ['Manager'])
        dummyMailHost = self._setup_mockmail()

        e = MailGroupAction()
        e.groups = ['group1']
        e.message = 'Document created !'
        ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)),
                             IExecutable)
        if IS_PLONE_5:
            ret = ex()
            self.assertFalse(ret)
        else:
            self.assertRaises(ValueError, ex)

        # if we provide a site mail address this won't fail anymore
        if IS_PLONE_5:
            from plone.registry.interfaces import IRegistry
            from Products.CMFPlone.interfaces import IMailSchema
            registry = getUtility(IRegistry)
            mail_settings = registry.forInterface(IMailSchema,
                                                  prefix='plone')

            mail_settings.email_from_address = '*****@*****.**'
            mail_settings.email_from_name = u'manager'
        else:
            sm = getSiteManager(self.portal)
            sm.manage_changeProperties({'email_from_address': '*****@*****.**'})

        ret = ex()

        mailSent = message_from_string(dummyMailHost.messages[0]['msg'])
        mailTo = dummyMailHost.messages[0]['mto'][0]
        mailFrom = mailSent.get('From')
        mailType = mailSent.get('Content-Type')
        self.assertTrue(mailType.startswith('multipart/related'))
        self.assertIn('*****@*****.**', mailTo)
        self.assertIn('*****@*****.**', mailFrom)
        self.assertIn('Document created !', str(mailSent))
 def testExecute(self):
     self.loginAsPortalOwner()
     sm = getSiteManager(self.portal)
     sm.unregisterUtility(provided=IMailHost)
     dummyMailHost = DummyMailHost('dMailhost')
     sm.registerUtility(dummyMailHost, IMailHost)
     e = MailGroupAction()
     e.source = "*****@*****.**"
     e.groups = [
         'group1',
     ]
     e.message = u"Päge '${title}' created in ${url} !"
     ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)),
                          IExecutable)
     ex()
     self.failUnless(isinstance(dummyMailHost.sent[0]['msg'], Message))
     mailSent = dummyMailHost.sent[0]['msg']
     self.assertTrue(
         mailSent.get('Content-Type').startswith('multipart/related'))
     self.assertEqual(None, mailSent.get('To'))
     self.assertEqual("*****@*****.**", mailSent.get('From'))
     self.assertIn(
         "P=C3=A4ge \'W=C3=A4lkommen\' created in http://nohost/plone/Members/test_user=\n_1_/d1",
         str(mailSent.get_payload()[0]))
 def testExecuteNoSource(self):
     self.loginAsPortalOwner()
     sm = getSiteManager(self.portal)
     sm.unregisterUtility(provided=IMailHost)
     dummyMailHost = DummySecureMailHost('dMailhost')
     sm.registerUtility(dummyMailHost, IMailHost)
     e = MailGroupAction()
     e.groups = ['group1', ]
     e.message = 'Document created !'
     ex = getMultiAdapter((self.folder, e, DummyEvent(self.folder.d1)),
                          IExecutable)
     self.assertRaises(ValueError, ex)
     # if we provide a site mail address this won't fail anymore
     sm.manage_changeProperties({'email_from_address': '*****@*****.**'})
     ex()
     self.failUnless(isinstance(dummyMailHost.sent[0], MIMEText))
     mailSent = dummyMailHost.sent[0]
     self.assertEqual('text/plain; charset="utf-8"',
                     mailSent.get('Content-Type'))
     self.assertEqual("*****@*****.**", mailSent.get('To'))
     self.assertEqual("Site Administrator <*****@*****.**>",
                      mailSent.get('From'))
     self.assertEqual("Document created !",
                      mailSent.get_payload(decode=True))