def setUp(self):
        """
        Create a site store and a user store with the L{Focus} powerup.
        """
        # Make the site store within which the test user will be created.
        self.dbdir = self.mktemp()
        self.siteStore = Store(self.dbdir)
        Mantissa().installSite(self.siteStore, u'example.com', u"", False)

        # Create a store for the user which is set up appropriately.
        self.userAccount = Create().addAccount(self.siteStore, u'testuser',
                                               u'example.com', u'password')
        self.userStore = self.userAccount.avatars.open()
        self.focus = Focus(store=self.userStore)
        installOn(self.focus, self.userStore)
Beispiel #2
0
def inbox4to5(old):
    """
    Copy over all attributes and add a reference to a newly created Focus item.
    Focus did not exist prior to the addition of this dependency, so there is
    no way one could exist in the store of an existing Inbox.

    Additionally, find or create a spam.Filter.  See inbox3to4.
    """
    focus = Focus(store=old.store)

    new = old.upgradeVersion(
        Inbox.typeName, 4, 5,
        privateApplication=old.privateApplication,
        messageSource=old.messageSource,
        quotientPrefs=old.quotientPrefs,
        deliveryAgent=old.deliveryAgent,
        messageDisplayPrefs=old.messageDisplayPrefs,
        uiComplexity=old.uiComplexity,
        showMoreDetail=old.showMoreDetail)

    src = old.store.findUnique(MessageSource)
    if installedOn(src) is None:
        #MessageSource was created in pre-dependency-system days
        _DependencyConnector(installee=src, target=old.store,
                             explicitlyInstalled=True,
                             store=old.store)
    filter = new.store.findFirst(spam.Filter, default=None)
    if filter is None:
        filter = spam.Filter(store=new.store)
    new.filter = filter

    new.focus = focus
    return new
Beispiel #3
0
    def setUp(self):
        """
        Create a site store and a user store with the L{Focus} powerup.
        """
        # Make the site store within which the test user will be created.
        self.dbdir = self.mktemp()
        self.siteStore = Store(self.dbdir)
        Mantissa().installSite(self.siteStore, u'example.com', u"", False)

        # Create a store for the user which is set up appropriately.
        self.userAccount = Create().addAccount(
            self.siteStore, u'testuser', u'example.com', u'password')
        self.userStore = self.userAccount.avatars.open()
        self.focus = Focus(store=self.userStore)
        installOn(self.focus, self.userStore)
class FocusTests(TestCase):
    """
    Tests for the code which determines if a message is focused or not.
    """
    def setUp(self):
        """
        Create a site store and a user store with the L{Focus} powerup.
        """
        # Make the site store within which the test user will be created.
        self.dbdir = self.mktemp()
        self.siteStore = Store(self.dbdir)
        Mantissa().installSite(self.siteStore, u'example.com', u"", False)

        # Create a store for the user which is set up appropriately.
        self.userAccount = Create().addAccount(self.siteStore, u'testuser',
                                               u'example.com', u'password')
        self.userStore = self.userAccount.avatars.open()
        self.focus = Focus(store=self.userStore)
        installOn(self.focus, self.userStore)

    def test_suspend(self):
        """
        Make sure the suspend method does nothing.
        """
        self.focus.suspend()

    def test_resume(self):
        """
        Make sure the resume method does nothing.
        """
        self.focus.resume()

    def test_nonPart(self):
        """
        Test that a message with an implementation which isn't a L{Part} that
        the Message doesn't get focused.

        This is primarily here for completeness at this point.  The only
        non-Part Messages which exist are probably created by the test suite.
        """
        impl = DummyMessageImplementation(store=self.userStore)
        message = Message.createIncoming(self.userStore, impl,
                                         u'test://test_nonPart')
        self.focus.processItem(message)
        statuses = set(message.iterStatuses())
        self.failIfIn(FOCUS_STATUS, statuses)

    def _focusedTest(self, part):
        message = Message.createIncoming(self.userStore, part,
                                         u'test://test_otherPrecedence')
        self.focus.processItem(message)
        statuses = set(message.iterStatuses())
        self.failUnlessIn(FOCUS_STATUS, statuses)

    def _unfocusedTest(self, part):
        message = Message.createIncoming(self.userStore, part,
                                         u'test://unfocused')
        self.focus.processItem(message)
        statuses = set(message.iterStatuses())
        self.failIfIn(FOCUS_STATUS, statuses)

    def test_bulkPrecedence(self):
        """
        Test that an email message with C{bulk} precedence is not focused.
        """
        impl = Part()
        impl.addHeader(u'Precedence', u'bulk')
        self._unfocusedTest(impl)

        impl = Part()
        impl.addHeader(u'Precedence', u'BuLK')
        self._unfocusedTest(impl)

    def test_listPrecedence(self):
        """
        Test that an email message with C{list} precedence is not focused.
        """
        impl = Part()
        impl.addHeader(u'Precedence', u'list')
        self._unfocusedTest(impl)

        impl = Part()
        impl.addHeader(u'Precedence', u'LIsT')
        self._unfocusedTest(impl)

    def test_otherPrecedence(self):
        """
        Test that an email message with some random other precedence header
        value is focused.
        """
        impl = Part()
        impl.addHeader(u'Precedence', u'made up random value')
        self._focusedTest(impl)

    def test_noPrecedence(self):
        """
        Test that an email message with no precedence header is focused.
        """
        impl = Part()
        self._focusedTest(impl)

    def test_draft(self):
        """
        Verify that a draft is not focused.
        """
        impl = Part()
        message = Message.createDraft(self.userStore, impl,
                                      u'test://test_draft')
        self.focus.processItem(message)
        statuses = set(message.iterStatuses())
        self.failIfIn(FOCUS_STATUS, statuses)

    def test_outbox(self):
        """
        Verify that a message in the outbox is not focused.
        """
        impl = Part()
        message = Message.createDraft(self.userStore, impl,
                                      u'test://test_outbox')
        message.startedSending()
        self.focus.processItem(message)
        statuses = set(message.iterStatuses())
        self.failIfIn(FOCUS_STATUS, statuses)

    def test_bounced(self):
        """
        Verify that a message which has bounced is not focused.
        """
        impl = Part()
        message = Message.createDraft(self.userStore, impl,
                                      u'test://test_bounced')
        message.startedSending()
        message.allBounced()
        self.focus.processItem(message)
        statuses = set(message.iterStatuses())
        self.failIfIn(FOCUS_STATUS, statuses)

    def test_partiallySent(self):
        """
        Verify that a message which has been sent to one recipient is not
        focused.
        """
        impl = Part()
        message = Message.createDraft(self.userStore, impl,
                                      u'test://test_partiallySent')
        message.startedSending()
        message.sent()
        self.focus.processItem(message)
        statuses = set(message.iterStatuses())
        self.failIfIn(FOCUS_STATUS, statuses)

    def test_finishedSending(self):
        """
        Verify that a message which has been sent to all recipients is not
        focused.
        """
        impl = Part()
        message = Message.createDraft(self.userStore, impl,
                                      u'test://test_finishedSending')
        message.startedSending()
        message.sent()
        message.finishedSending()
        self.focus.processItem(message)
        statuses = set(message.iterStatuses())
        self.failIfIn(FOCUS_STATUS, statuses)
Beispiel #5
0
class FocusTests(TestCase):
    """
    Tests for the code which determines if a message is focused or not.
    """
    def setUp(self):
        """
        Create a site store and a user store with the L{Focus} powerup.
        """
        # Make the site store within which the test user will be created.
        self.dbdir = self.mktemp()
        self.siteStore = Store(self.dbdir)
        Mantissa().installSite(self.siteStore, u'example.com', u"", False)

        # Create a store for the user which is set up appropriately.
        self.userAccount = Create().addAccount(
            self.siteStore, u'testuser', u'example.com', u'password')
        self.userStore = self.userAccount.avatars.open()
        self.focus = Focus(store=self.userStore)
        installOn(self.focus, self.userStore)


    def test_suspend(self):
        """
        Make sure the suspend method does nothing.
        """
        self.focus.suspend()


    def test_resume(self):
        """
        Make sure the resume method does nothing.
        """
        self.focus.resume()


    def test_nonPart(self):
        """
        Test that a message with an implementation which isn't a L{Part} that
        the Message doesn't get focused.

        This is primarily here for completeness at this point.  The only
        non-Part Messages which exist are probably created by the test suite.
        """
        impl = DummyMessageImplementation(store=self.userStore)
        message = Message.createIncoming(
            self.userStore, impl, u'test://test_nonPart')
        self.focus.processItem(message)
        statuses = set(message.iterStatuses())
        self.failIfIn(FOCUS_STATUS, statuses)


    def _focusedTest(self, part):
        message = Message.createIncoming(
            self.userStore, part, u'test://test_otherPrecedence')
        self.focus.processItem(message)
        statuses = set(message.iterStatuses())
        self.failUnlessIn(FOCUS_STATUS, statuses)


    def _unfocusedTest(self, part):
        message = Message.createIncoming(
            self.userStore, part, u'test://unfocused')
        self.focus.processItem(message)
        statuses = set(message.iterStatuses())
        self.failIfIn(FOCUS_STATUS, statuses)


    def test_bulkPrecedence(self):
        """
        Test that an email message with C{bulk} precedence is not focused.
        """
        impl = Part()
        impl.addHeader(u'Precedence', u'bulk')
        self._unfocusedTest(impl)

        impl = Part()
        impl.addHeader(u'Precedence', u'BuLK')
        self._unfocusedTest(impl)


    def test_listPrecedence(self):
        """
        Test that an email message with C{list} precedence is not focused.
        """
        impl = Part()
        impl.addHeader(u'Precedence', u'list')
        self._unfocusedTest(impl)

        impl = Part()
        impl.addHeader(u'Precedence', u'LIsT')
        self._unfocusedTest(impl)


    def test_otherPrecedence(self):
        """
        Test that an email message with some random other precedence header
        value is focused.
        """
        impl = Part()
        impl.addHeader(u'Precedence', u'made up random value')
        self._focusedTest(impl)


    def test_noPrecedence(self):
        """
        Test that an email message with no precedence header is focused.
        """
        impl = Part()
        self._focusedTest(impl)


    def test_draft(self):
        """
        Verify that a draft is not focused.
        """
        impl = Part()
        message = Message.createDraft(
            self.userStore, impl, u'test://test_draft')
        self.focus.processItem(message)
        statuses = set(message.iterStatuses())
        self.failIfIn(FOCUS_STATUS, statuses)


    def test_outbox(self):
        """
        Verify that a message in the outbox is not focused.
        """
        impl = Part()
        message = Message.createDraft(
            self.userStore, impl, u'test://test_outbox')
        message.startedSending()
        self.focus.processItem(message)
        statuses = set(message.iterStatuses())
        self.failIfIn(FOCUS_STATUS, statuses)


    def test_bounced(self):
        """
        Verify that a message which has bounced is not focused.
        """
        impl = Part()
        message = Message.createDraft(
            self.userStore, impl, u'test://test_bounced')
        message.startedSending()
        message.allBounced()
        self.focus.processItem(message)
        statuses = set(message.iterStatuses())
        self.failIfIn(FOCUS_STATUS, statuses)


    def test_partiallySent(self):
        """
        Verify that a message which has been sent to one recipient is not
        focused.
        """
        impl = Part()
        message = Message.createDraft(
            self.userStore, impl, u'test://test_partiallySent')
        message.startedSending()
        message.sent()
        self.focus.processItem(message)
        statuses = set(message.iterStatuses())
        self.failIfIn(FOCUS_STATUS, statuses)


    def test_finishedSending(self):
        """
        Verify that a message which has been sent to all recipients is not
        focused.
        """
        impl = Part()
        message = Message.createDraft(
            self.userStore, impl, u'test://test_finishedSending')
        message.startedSending()
        message.sent()
        message.finishedSending()
        self.focus.processItem(message)
        statuses = set(message.iterStatuses())
        self.failIfIn(FOCUS_STATUS, statuses)