예제 #1
0
    def afterSetUp(self):
        super(ProcessSignalTaskTest, self).afterSetUp()

        from zope.component import getGlobalSiteManager
        # register the component
        gsm = getGlobalSiteManager()

        self.emailAction = EmailMockAction()
        self.pageAction = PageMockAction()
        gsm.registerUtility(self.emailAction, IAction, self.emailAction.id)
        gsm.registerUtility(self.pageAction, IAction, self.pageAction.id)

        self.mockDao = MockNotificationDao()
        self.taskProcessor = ProcessSignalTask(self.mockDao)
예제 #2
0
class ProcessSignalTaskTest(BaseTestCase):
    def afterSetUp(self):
        super(ProcessSignalTaskTest, self).afterSetUp()

        from zope.component import getGlobalSiteManager
        # register the component
        gsm = getGlobalSiteManager()

        self.emailAction = EmailMockAction()
        self.pageAction = PageMockAction()
        gsm.registerUtility(self.emailAction, IAction, self.emailAction.id)
        gsm.registerUtility(self.pageAction, IAction, self.pageAction.id)

        self.mockDao = MockNotificationDao()
        self.taskProcessor = ProcessSignalTask(self.mockDao)

    def testEnabledNotification(self):
        """
        Test that a notification subscription matches a signal and that the
        action for the notification executes.
        """

        self.mockDao.notifications = [active_email_notification]
        self.taskProcessor.processSignal(test_signal1)

        expected_recipients = list(
            set([
                recipient['value']
                for recipient in active_email_notification.recipients
            ]))
        assert self.emailAction.result == expected_recipients

    def testEnabledNotificationPage(self):
        self.mockDao.notifications = [active_page_notification]
        self.taskProcessor.processSignal(test_signal1)
        expected_recipients = list(
            set([
                recipient['value']
                for recipient in active_page_notification.recipients
            ]))
        assert self.pageAction.result == expected_recipients

    def testDisabledNotification(self):
        """
        Test that a disabled notification does not execute any actions.
        """
        self.mockDao.notifications = [disabled_notification]
        self.taskProcessor.processSignal(test_signal1)

        assert self.emailAction.result == []

    def testWithoutRecipients(self):
        """
        Test that nothing happens gracefully when a notificaiton does not have
        any recipients.
        """
        self.mockDao.notifications = [active_notification_zero]
        self.taskProcessor.processSignal(test_signal1)

        assert self.emailAction.result == []
예제 #3
0
class ProcessSignalTaskTest(BaseTestCase):

    def afterSetUp(self):
        super(ProcessSignalTaskTest, self).afterSetUp()

        from zope.component import getGlobalSiteManager
        # register the component
        gsm = getGlobalSiteManager()

        self.emailAction = EmailMockAction()
        self.pageAction = PageMockAction()
        gsm.registerUtility(self.emailAction, IAction, self.emailAction.id)
        gsm.registerUtility(self.pageAction, IAction, self.pageAction.id)

        self.mockDao = MockNotificationDao()
        self.taskProcessor = ProcessSignalTask(self.mockDao)
        self.taskProcessor.dmd = self.dmd

    def testEnabledNotification(self):
        """
        Test that a notification subscription matches a signal and that the
        action for the notification executes.
        """

        self.mockDao.notifications = [active_email_notification]
        self.taskProcessor.processSignal(test_signal1)

        expected_recipients = list(set(
            [recipient['value'] for recipient in active_email_notification.recipients]
        ))
        assert self.emailAction.result == expected_recipients

    def testEnabledNotificationPage(self):
        self.mockDao.notifications = [active_page_notification]
        self.taskProcessor.processSignal(test_signal1)
        expected_recipients = list(set(
            [recipient['value'] for recipient in active_page_notification.recipients]
        ))
        assert self.pageAction.result == expected_recipients

    def testDisabledNotification(self):
        """
        Test that a disabled notification does not execute any actions.
        """
        self.mockDao.notifications = [disabled_notification]
        self.taskProcessor.processSignal(test_signal1)

        assert self.emailAction.result == []

    def testWithoutRecipients(self):
        """
        Test that nothing happens gracefully when a notificaiton does not have
        any recipients.
        """
        self.mockDao.notifications = [active_notification_zero]
        self.taskProcessor.processSignal(test_signal1)

        assert self.emailAction.result == []
    def afterSetUp(self):
        super(ProcessSignalTaskTest, self).afterSetUp()
        
        from zope.component import getGlobalSiteManager
        # register the component
        gsm = getGlobalSiteManager()

        self.emailAction = EmailMockAction()
        self.pageAction = PageMockAction()
        gsm.registerUtility(self.emailAction, IAction, self.emailAction.id)
        gsm.registerUtility(self.pageAction, IAction, self.pageAction.id)

        self.mockDao = MockNotificationDao()
        self.taskProcessor = ProcessSignalTask(self.mockDao)