def setUp(self):
     """
     """
     app = self.layer['app']
     self.portal = self.layer['portal']
     self.request = self.layer['request']
     self.tool = getToolByName(self.portal, SUBSCRIPTION_TOOL, None)
     self.markRequestWithLayer()
     self.portal_url = self.portal.absolute_url()
     self.browser = Browser(app)
     self.browser.addHeader(
         'Authorization', 'Basic %s:%s' % (
             SITE_OWNER_NAME,
             SITE_OWNER_PASSWORD,
         ))
     #Create some rules
     for x in ["first", "second", "third"]:
         #set some rules
         rule = Rule()
         rule.event = IObjectAddedEvent
         rule.title = "%s rule" % x
         #add the rules to rule's storage
         storage = getUtility(IRuleStorage)
         chooser = INameChooser(storage)
         storage[chooser.chooseName(None, rule)] = rule
         #set the action and add it to the rule
         action = MailSubscriptionsAction()
         action.subject = "Test %s action subject" % x
         rule.actions.append(action)
         email1 = "*****@*****.**"
         email2 = "*****@*****.**"
         self.tool.registerUser(action.actionUID, email1)
         self.tool.registerUser(action.actionUID, email2)
     transaction.commit()
コード例 #2
0
 def testExecuteNoSource(self):
     sm = getSiteManager(self.portal)
     sm.unregisterUtility(provided=IMailHost)
     dummyMailHost = DummyMailHost('dMailhost')
     sm.registerUtility(dummyMailHost, IMailHost)
     e = MailSubscriptionsAction()
     e.message = 'Document created !'
     e.subject = "subject"
     self.tool.registerUser(e.actionUID, "*****@*****.**")
     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_name': 'The Big Boss',
                                 'email_from_address': '*****@*****.**',
                                 })
     ex()
     self.failUnless(isinstance(dummyMailHost.sent[0], Message))
     mailSent = dummyMailHost.sent[0]
     self.assertEqual('text/plain; charset="utf-8"',
                     mailSent.get('Content-Type'))
     self.assertEqual("*****@*****.**", mailSent.get('To'))
     self.assertEqual("The Big Boss <*****@*****.**>",
                      mailSent.get('From'))
     self.assertEqual("Document created !",
                      mailSent.get_payload(decode=True))
コード例 #3
0
 def testExecuteNoSource(self):
     sm = getSiteManager(self.portal)
     sm.unregisterUtility(provided=IMailHost)
     dummyMailHost = DummyMailHost('dMailhost')
     sm.registerUtility(dummyMailHost, IMailHost)
     e = MailSubscriptionsAction()
     e.message = 'Document created !'
     e.subject = "subject"
     self.tool.registerUser(e.actionUID, "*****@*****.**")
     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_name': 'The Big Boss',
         'email_from_address': '*****@*****.**',
     })
     ex()
     self.failUnless(isinstance(dummyMailHost.sent[0], Message))
     mailSent = dummyMailHost.sent[0]
     self.assertEqual('text/plain; charset="utf-8"',
                      mailSent.get('Content-Type'))
     self.assertEqual("*****@*****.**", mailSent.get('To'))
     self.assertEqual("The Big Boss <*****@*****.**>",
                      mailSent.get('From'))
     self.assertEqual("Document created !",
                      mailSent.get_payload(decode=True))
 def setUp(self):
     """
     """
     app = self.layer['app']
     self.portal = self.layer['portal']
     self.request = self.layer['request']
     self.tool = getToolByName(self.portal, SUBSCRIPTION_TOOL, None)
     self.markRequestWithLayer()
     self.portal_url = self.portal.absolute_url()
     self.browser = Browser(app)
     self.browser.addHeader('Authorization', 'Basic %s:%s' % (SITE_OWNER_NAME, SITE_OWNER_PASSWORD,))
     #Create some rules
     for x in ["first", "second", "third"]:
         #set some rules
         rule = Rule()
         rule.event = IObjectAddedEvent
         rule.title = "%s rule" % x
         #add the rules to rule's storage
         storage = getUtility(IRuleStorage)
         chooser = INameChooser(storage)
         storage[chooser.chooseName(None, rule)] = rule
         #set the action and add it to the rule
         action = MailSubscriptionsAction()
         action.subject = "Test %s action subject" % x
         rule.actions.append(action)
         email1 = "*****@*****.**"
         email2 = "*****@*****.**"
         self.tool.registerUser(action.actionUID, email1)
         self.tool.registerUser(action.actionUID, email2)
     transaction.commit()
コード例 #5
0
 def testInvokeEditView(self):
     element = getUtility(IRuleAction,
                          name='plone.actions.MailSubscriptions')
     e = MailSubscriptionsAction()
     editview = getMultiAdapter((e, self.folder.REQUEST),
                                name=element.editview)
     self.failUnless(isinstance(editview, MailSubscriptionsEditForm))
コード例 #6
0
 def test_already_registered_email(self):
     """
     try to re-register an email for the same rule id
     """
     rule = Rule()
     rule.event = IObjectAddedEvent
     rule.title = "Test rule"
     #add the rule to rule's storage
     storage = getUtility(IRuleStorage)
     chooser = INameChooser(storage)
     storage[chooser.chooseName(None, rule)] = rule
     #set the action and add it to the rule
     action = MailSubscriptionsAction()
     action.subject = "Test Rule subject"
     action.message = "Test Rule message"
     rule.actions.append(action)
     tool = getToolByName(self.portal, SUBSCRIPTION_TOOL, None)
     email = "*****@*****.**"
     result, msg = tool.registerUser(action.actionUID, email)
     result2, msg2 = tool.registerUser(action.actionUID, email)
     self.assertTrue(result)
     self.assertFalse(result2)
     self.assertEquals(msg2, 'already_subscribed_error')
 def setUp(self):
     """
     """
     self.portal = self.layer['portal']
     self.request = self.layer['request']
     self.markRequestWithLayer()
     # Creating empty value for ACTUAL_URL to prevent KeyError
     self.request['ACTUAL_URL'] = ''
     app = self.layer['app']
     #set some things
     #create a test user with email
     self.acl_users = getToolByName(self.portal, 'acl_users')
     self.acl_users.userFolderAddUser('user1', 'secret', ['Member'], [])
     self.user1 = self.acl_users.getUser('user1')
     self.user1.setProperties(email='*****@*****.**')
     #now set some rules
     self.tool = getToolByName(self.portal, SUBSCRIPTION_TOOL, None)
     self.portal_url = self.portal.absolute_url()
     self.browser = Browser(app)
     for x in ["first", "second", "third"]:
         #set some rules
         rule = Rule()
         rule.event = IObjectAddedEvent
         rule.title = "%s rule" % x
         #add the rules to rule's storage
         storage = getUtility(IRuleStorage)
         chooser = INameChooser(storage)
         storage[chooser.chooseName(None, rule)] = rule
         #set the action and add it to the rule
         action = MailSubscriptionsAction()
         action.subject = "Test %s action subject" % x
         rule.actions.append(action)
     #set one only norobots question
     registry = queryUtility(IRegistry)
     settings = registry.forInterface(INorobotsWidgetSettings, check=False)
     settings.questions = (u'What is 4 + 4 ?::8', )
     transaction.commit()
 def setUp(self):
     """
     """
     self.portal = self.layer['portal']
     self.request = self.layer['request']
     self.markRequestWithLayer()
     # Creating empty value for ACTUAL_URL to prevent KeyError
     self.request['ACTUAL_URL'] = ''
     app = self.layer['app']
     #set some things
     #create a test user with email
     self.acl_users = getToolByName(self.portal, 'acl_users')
     self.acl_users.userFolderAddUser('user1', 'secret', ['Member'], [])
     self.user1 = self.acl_users.getUser('user1')
     self.user1.setProperties(email='*****@*****.**')
     #now set some rules
     self.tool = getToolByName(self.portal, SUBSCRIPTION_TOOL, None)
     self.portal_url = self.portal.absolute_url()
     self.browser = Browser(app)
     for x in ["first", "second", "third"]:
         #set some rules
         rule = Rule()
         rule.event = IObjectAddedEvent
         rule.title = "%s rule" % x
         #add the rules to rule's storage
         storage = getUtility(IRuleStorage)
         chooser = INameChooser(storage)
         storage[chooser.chooseName(None, rule)] = rule
         #set the action and add it to the rule
         action = MailSubscriptionsAction()
         action.subject = "Test %s action subject" % x
         rule.actions.append(action)
     #set one only norobots question
     registry = queryUtility(IRegistry)
     settings = registry.forInterface(INorobotsWidgetSettings, check=False)
     settings.questions = (u'What is 4 + 4 ?::8',)
     transaction.commit()