def setUp(self): """ Make a draft message using an L{xquotient.iquotient.IMessageData} with a bunch of related addresses """ self.store = Store() self.messageData = DummyMessageImplWithABunchOfAddresses( store=self.store) self.message = Message.createDraft( self.store, self.messageData, u'test')
def setUp(self): """ Make a draft message using an L{xquotient.iquotient.IMessageData} with a bunch of related addresses """ self.store = Store() self.messageData = DummyMessageImplWithABunchOfAddresses( store=self.store) self.message = Message.createDraft(self.store, self.messageData, u'test')
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_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_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_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_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 testMessageFactory(store, archived=False, spam=None, read=False, sentWhen=None, receivedWhen=None, subject=u'', trash=False, outgoing=False, draft=False, impl=None, sent=True, bounced=False, sender=None, recipient=u''): """ Provide a simulacrum of message's old constructor signature to avoid unnecessarily deep modification of tests. @return: an exmess.Message object. """ if impl is None: impl = DummyMessageImplementation(store=store) if sender is not None: impl.senderInfo = sender if outgoing: m = Message.createDraft(store, impl, u'test://test/draft') if not draft: # XXX: this is *actually* the status change that transpires when # you transition a message from "draft" to "sent" status. m.startedSending() if sent: m.sent() m.finishedSending() elif bounced: m.allBounced() if spam is not None: assert spam is False, "That doesn't make any sense." else: m = Message.createIncoming(store, impl, u'test://test') if spam is not None: if spam: m.classifySpam() else: m.classifyClean() m.subject = subject m.recipient = recipient # should this be handled somewhere else? ugh. if read: m.markRead() if archived: m.archive() if trash: m.moveToTrash() # these next bits are definitely wrong. they should be set up by analysis # of the body part, probably? if receivedWhen: m.receivedWhen = receivedWhen # we're supplying our own received date, after message creation, but # this won't be reflected in the statusDate of the statuses that were # added to the message as a result of createIncoming, so we'll remove # them all and re-add them for s in m.iterStatuses(): m.removeStatus(s) m.addStatus(s) if sentWhen: m.sentWhen = sentWhen if sender: m.sender = sender m.senderDisplay = sender # Cheat so that nit test setup will work; this is gross, but inverting # it to be specified properly (in the tests' impl) would be even more # of a pain in the ass right now... -glyph Correspondent(store=store, relation=SENDER_RELATION, message=m, address=sender) return m
def testMessageFactory(store, archived=False, spam=None, read=False, sentWhen=None, receivedWhen=None, subject=u'', trash=False, outgoing=False, draft=False, impl=None, sent=True, bounced=False, sender=None, recipient=u''): """ Provide a simulacrum of message's old constructor signature to avoid unnecessarily deep modification of tests. @return: an exmess.Message object. """ if impl is None: impl = DummyMessageImplementation(store=store) if sender is not None: impl.senderInfo = sender if outgoing: m = Message.createDraft(store, impl, u'test://test/draft') if not draft: # XXX: this is *actually* the status change that transpires when # you transition a message from "draft" to "sent" status. m.startedSending() if sent: m.sent() m.finishedSending() elif bounced: m.allBounced() if spam is not None: assert spam is False, "That doesn't make any sense." else: m = Message.createIncoming(store, impl, u'test://test') if spam is not None: if spam: m.classifySpam() else: m.classifyClean() m.subject = subject m.recipient = recipient # should this be handled somewhere else? ugh. if read: m.markRead() if archived: m.archive() if trash: m.moveToTrash() # these next bits are definitely wrong. they should be set up by analysis # of the body part, probably? if receivedWhen: m.receivedWhen = receivedWhen # we're supplying our own received date, after message creation, but # this won't be reflected in the statusDate of the statuses that were # added to the message as a result of createIncoming, so we'll remove # them all and re-add them for s in m.iterStatuses(): m.removeStatus(s) m.addStatus(s) if sentWhen: m.sentWhen = sentWhen if sender: m.sender = sender m.senderDisplay = sender # Cheat so that nit test setup will work; this is gross, but inverting # it to be specified properly (in the tests' impl) would be even more # of a pain in the ass right now... -glyph Correspondent(store=store, relation=SENDER_RELATION, message=m, address=sender) return m