def getControllerWidget(self): """ Retrieve the Controller widget for a mailbox with no message in the inbox view but several messages in the archive view. """ inbox = self.getInbox() offset = timedelta(seconds=30) impl = _Part(store=inbox.store) # Archive messages m1 = testMessageFactory(store=inbox.store, sender=self.aliceEmail, subject=u'1st message', receivedWhen=self.sent, sentWhen=self.sent, spam=False, archived=True, read=False, impl=impl) m2 = testMessageFactory(store=inbox.store, sender=self.aliceEmail, subject=u'2nd message', receivedWhen=self.sent + offset, sentWhen=self.sent, spam=False, archived=True, read=False, impl=impl) return self.widgetFor(inbox)
def getFocusControllerWidget(self): """ Retrieve the Controller widget for a mailbox with two messages, one focused and one not. """ inbox = self.getInbox() inbox.uiComplexity = 3 impl = _Part(store=inbox.store) # One focused message m = testMessageFactory(store=inbox.store, sender=self.aliceEmail, subject=u'focused message', receivedWhen=self.sent, sentWhen=self.sent2, spam=False, archived=False, read=True, impl=impl) m.focus() # One unfocused message in the inbox testMessageFactory(store=inbox.store, sender=self.aliceEmail, subject=u'unfocused message', receivedWhen=self.sent, sentWhen=self.sent2, spam=False, archived=False, read=True, impl=impl) return self.widgetFor(inbox)
def getScrollingWidget(self, howManyElements=0): store = Store() installOn(PrivateApplication(store=store), store) for n in xrange(howManyElements): testMessageFactory(store, spam=False) f = MailboxScrollingFragment(store) f.docFactory = getLoader(f.fragmentName) f.setFragmentParent(self) return f
def setUp(self): # XXX Incorrect setup. See xquotient.test.test_compose.CompositionTestMixin self.store = Store(self.mktemp()) LoginMethod(store=self.store, internal=False, protocol=u'email', localpart=u'recipient', domain=u'host', verified=True, account=self.store) self.fromAddr = smtpout.FromAddress(address=u'recipient@host', store=self.store) self.inbox = inbox.Inbox(store=self.store) installOn(self.inbox, self.store) self.composer = compose.Composer(store=self.store) installOn(self.composer, self.store) self.defaultFromAddress = self.store.findUnique( smtpout.FromAddress, smtpout.FromAddress._address == None) self.message = testMessageFactory( store=self.store, spam=False, impl=DummyMessageImplWithABunchOfAddresses(store=self.store)) self.messageDetail = MessageDetail(self.message)
def getFullControllerWidget(self): """ Retrieve the Controller widget for a mailbox with twenty messages in it. """ inbox = self.getInbox() inbox.uiComplexity = 3 catalog = inbox.store.findUnique(Catalog) impl = _Part(store=inbox.store) messages = [ testMessageFactory(store=inbox.store, sender=self.aliceEmail, subject=u'message %d' % (i, ), receivedWhen=self.sent, sentWhen=self.sent2, spam=False, archived=False, read=False, impl=impl) for i in range(20) ] catalog.tag(messages[1], u'foo') return self.widgetFor(inbox)
def test_peopleMessageListRendering(self): mlister = MessageLister(store=self.substore) installOn(mlister, self.substore) p = Person(store=self.substore, name=u'Bob') EmailAddress(store=self.substore, person=p, address=u'bob@internet') for i in xrange(5): testMessageFactory( store=self.substore, subject=unicode(str(i)), receivedWhen=Time(), spam=False, sender=u'bob@internet') self.assertEqual(len(list(mlister.mostRecentMessages(p))), 5) return renderPage( rend.Page(docFactory=loaders.stan(MessageList(mlister, p))))
def makeMessages(n, email): return list(reversed(list( testMessageFactory(store=s, subject=u'Message %d' % (i,), sender=email, spam=False, receivedWhen=Time()) for i in xrange(n))))
def test_peopleMessageListRendering(self): mlister = MessageLister(store=self.substore) installOn(mlister, self.substore) p = Person(store=self.substore, name=u'Bob') EmailAddress(store=self.substore, person=p, address=u'bob@internet') for i in xrange(5): testMessageFactory(store=self.substore, subject=unicode(str(i)), receivedWhen=Time(), spam=False, sender=u'bob@internet') self.assertEqual(len(list(mlister.mostRecentMessages(p))), 5) return renderPage( rend.Page(docFactory=loaders.stan(MessageList(mlister, p))))
def makeMessage(receiver, parts, impl): """ Create a new L{exmess.Message}, either by parsing C{parts} or by wrapping one around C{impl}. """ if impl is None: return receiver.feedStringNow(parts) else: return testMessageFactory(store=impl.store, receivedWhen=Time(), sentWhen=Time(), spam=False, subject=u'', impl=impl)
def getControllerWidget(self): """ Retrieve the Controller widget for a mailbox with no message in the inbox view but several messages in the archive view. """ inbox = self.getInbox() offset = timedelta(seconds=30) impl = _Part(store=inbox.store) # Archive messages m1 = testMessageFactory( store=inbox.store, sender=self.aliceEmail, subject=u'1st message', receivedWhen=self.sent, sentWhen=self.sent, spam=False, archived=True, read=False, impl=impl) m2 = testMessageFactory( store=inbox.store, sender=self.aliceEmail, subject=u'2nd message', receivedWhen=self.sent + offset, sentWhen=self.sent, spam=False, archived=True, read=False, impl=impl) return self.widgetFor(inbox)
def getFocusControllerWidget(self): """ Retrieve the Controller widget for a mailbox with two messages, one focused and one not. """ inbox = self.getInbox() inbox.uiComplexity = 3 impl = _Part(store=inbox.store) # One focused message m = testMessageFactory( store=inbox.store, sender=self.aliceEmail, subject=u'focused message', receivedWhen=self.sent, sentWhen=self.sent2, spam=False, archived=False, read=True, impl=impl) m.focus() # One unfocused message in the inbox testMessageFactory( store=inbox.store, sender=self.aliceEmail, subject=u'unfocused message', receivedWhen=self.sent, sentWhen=self.sent2, spam=False, archived=False, read=True, impl=impl) return self.widgetFor(inbox)
def setUp(self): self.store = Store(dbdir=self.mktemp()) installOn(inbox.Inbox(store=self.store), self.store) self.composer = compose.Composer(store=self.store) installOn(self.composer, self.store) LoginMethod(store=self.store, internal=False, protocol=u'email', localpart=u'recipient', domain=u'host', verified=True, account=self.store) self.msg = testMessageFactory( store=self.store, spam=False, impl=DummyMessageImplWithABunchOfAddresses(store=self.store)) self.msgDetail = MessageDetail(self.msg)
def getFullControllerWidget(self): """ Retrieve the Controller widget for a mailbox with twenty messages in it. """ inbox = self.getInbox() inbox.uiComplexity = 3 catalog = inbox.store.findUnique(Catalog) impl = _Part(store=inbox.store) messages = [ testMessageFactory(store=inbox.store, sender=self.aliceEmail, subject=u'message %d' % (i,), receivedWhen=self.sent, sentWhen=self.sent2, spam=False, archived=False, read=False, impl=impl) for i in range(20)] catalog.tag(messages[1], u'foo') return self.widgetFor(inbox)
def setUp(self): # XXX Incorrect setup. See xquotient.test.test_compose.CompositionTestMixin self.store = Store(self.mktemp()) LoginMethod(store=self.store, internal=False, protocol=u'email', localpart=u'recipient', domain=u'host', verified=True, account=self.store) self.fromAddr = smtpout.FromAddress( address=u'recipient@host', store=self.store) self.inbox = inbox.Inbox(store=self.store) installOn(self.inbox, self.store) self.composer = compose.Composer(store=self.store) installOn(self.composer, self.store) self.defaultFromAddress = self.store.findUnique( smtpout.FromAddress, smtpout.FromAddress._address == None) self.message = testMessageFactory( store=self.store, spam=False, impl=DummyMessageImplWithABunchOfAddresses(store=self.store)) self.messageDetail = MessageDetail(self.message)
def getControllerWidget(self): """ Retrieve the Controller widget for a mailbox in a particular configuration. The particulars of the email in this configuration are:: There are 5 messages total. The inbox contains 2 unread messages. The archive contains 2 read messages. The spam folder contains 1 unread message. The sent folter contains 1 read message. The trash folder contains 2 read messages. There are also some people. They are:: Alice - [email protected] Bob - [email protected] The 1st message in the inbox is tagged "foo". The 2nd message in the inbox is tagged "bar". """ inbox = self.getInbox() organizer = inbox.store.findUnique(Organizer) application = inbox.store.findUnique(PrivateApplication) catalog = inbox.store.findUnique(Catalog) offset = timedelta(seconds=30) impl = _Part(store=inbox.store) # Inbox messages m1 = testMessageFactory( store=inbox.store, sender=self.aliceEmail, subject=u'1st message', receivedWhen=self.sent + offset * 8, sentWhen=self.sent2, spam=False, archived=False, read=False, impl=impl) catalog.tag(m1, u"foo") m2 = testMessageFactory( store=inbox.store, sender=self.aliceEmail, subject=u'2nd message', receivedWhen=self.sent + offset * 7, sentWhen=self.sent, spam=False, archived=False, read=False, impl=impl) catalog.tag(m2, u"bar") # Archive messages m3 = testMessageFactory( store=inbox.store, sender=self.aliceEmail, subject=u'3rd message', receivedWhen=self.sent + offset * 6, sentWhen=self.sent, spam=False, archived=True, read=True, impl=impl) m4 = testMessageFactory( store=inbox.store, sender=self.aliceEmail, subject=u'4th message', receivedWhen=self.sent + offset * 5, sentWhen=self.sent, spam=False, archived=True, read=True, impl=impl) # Spam message m5 = testMessageFactory( store=inbox.store, sender=self.bobEmail, subject=u'5th message', receivedWhen=self.sent + offset * 4, sentWhen=self.sent, spam=True, archived=False, read=False, impl=impl) # Sent message m6 = testMessageFactory( store=inbox.store, sender=self.bobEmail, subject=u'6th message', receivedWhen=self.sent + offset * 3, sentWhen=self.sent, spam=False, archived=False, read=True, outgoing=True, recipient=self.aliceEmail, impl=impl) # Trash messages m7 = testMessageFactory( store=inbox.store, sender=self.bobEmail, subject=u'7th message', receivedWhen=self.sent + offset * 2, sentWhen=self.sent, spam=False, archived=False, read=True, outgoing=False, trash=True, impl=impl) m8 = testMessageFactory( store=inbox.store, sender=self.bobEmail, subject=u'8th message', receivedWhen=self.sent + offset, sentWhen=self.sent, spam=False, archived=False, read=True, outgoing=False, trash=True, impl=impl) m9 = testMessageFactory( store=inbox.store, sender=self.aliceEmail, subject=u'9th message', receivedWhen=self.sent, sentWhen=self.sent, spam=False, archived=False, read=True, outgoing=False, trash=True, impl=impl) # Alice alice = Person(store=inbox.store, organizer=organizer, name=u"Alice") EmailAddress(store=inbox.store, person=alice, address=self.aliceEmail) # Bob bob = Person(store=inbox.store, organizer=organizer, name=u"Bob") EmailAddress(store=inbox.store, person=bob, address=self.bobEmail) self.names = { application.toWebID(alice): u'Alice', application.toWebID(bob): u'Bob'} self.messages = dict( (application.toWebID(m), m) for m in [m1, m2, m3, m4, m5, m6, m7, m8]) return self.widgetFor(inbox)
def getControllerWidget(self): """ Retrieve the Controller widget for a mailbox in a particular configuration. The particulars of the email in this configuration are:: There are 5 messages total. The inbox contains 2 unread messages. The archive contains 2 read messages. The spam folder contains 1 unread message. The sent folter contains 1 read message. The trash folder contains 2 read messages. There are also some people. They are:: Alice - [email protected] Bob - [email protected] The 1st message in the inbox is tagged "foo". The 2nd message in the inbox is tagged "bar". """ inbox = self.getInbox() organizer = inbox.store.findUnique(Organizer) application = inbox.store.findUnique(PrivateApplication) catalog = inbox.store.findUnique(Catalog) offset = timedelta(seconds=30) impl = _Part(store=inbox.store) # Inbox messages m1 = testMessageFactory(store=inbox.store, sender=self.aliceEmail, subject=u'1st message', receivedWhen=self.sent + offset * 8, sentWhen=self.sent2, spam=False, archived=False, read=False, impl=impl) catalog.tag(m1, u"foo") m2 = testMessageFactory(store=inbox.store, sender=self.aliceEmail, subject=u'2nd message', receivedWhen=self.sent + offset * 7, sentWhen=self.sent, spam=False, archived=False, read=False, impl=impl) catalog.tag(m2, u"bar") # Archive messages m3 = testMessageFactory(store=inbox.store, sender=self.aliceEmail, subject=u'3rd message', receivedWhen=self.sent + offset * 6, sentWhen=self.sent, spam=False, archived=True, read=True, impl=impl) m4 = testMessageFactory(store=inbox.store, sender=self.aliceEmail, subject=u'4th message', receivedWhen=self.sent + offset * 5, sentWhen=self.sent, spam=False, archived=True, read=True, impl=impl) # Spam message m5 = testMessageFactory(store=inbox.store, sender=self.bobEmail, subject=u'5th message', receivedWhen=self.sent + offset * 4, sentWhen=self.sent, spam=True, archived=False, read=False, impl=impl) # Sent message m6 = testMessageFactory(store=inbox.store, sender=self.bobEmail, subject=u'6th message', receivedWhen=self.sent + offset * 3, sentWhen=self.sent, spam=False, archived=False, read=True, outgoing=True, recipient=self.aliceEmail, impl=impl) # Trash messages m7 = testMessageFactory(store=inbox.store, sender=self.bobEmail, subject=u'7th message', receivedWhen=self.sent + offset * 2, sentWhen=self.sent, spam=False, archived=False, read=True, outgoing=False, trash=True, impl=impl) m8 = testMessageFactory(store=inbox.store, sender=self.bobEmail, subject=u'8th message', receivedWhen=self.sent + offset, sentWhen=self.sent, spam=False, archived=False, read=True, outgoing=False, trash=True, impl=impl) m9 = testMessageFactory(store=inbox.store, sender=self.aliceEmail, subject=u'9th message', receivedWhen=self.sent, sentWhen=self.sent, spam=False, archived=False, read=True, outgoing=False, trash=True, impl=impl) # Alice alice = Person(store=inbox.store, organizer=organizer, name=u"Alice") EmailAddress(store=inbox.store, person=alice, address=self.aliceEmail) # Bob bob = Person(store=inbox.store, organizer=organizer, name=u"Bob") EmailAddress(store=inbox.store, person=bob, address=self.bobEmail) self.names = { application.toWebID(alice): u'Alice', application.toWebID(bob): u'Bob' } self.messages = dict((application.toWebID(m), m) for m in [m1, m2, m3, m4, m5, m6, m7, m8]) return self.widgetFor(inbox)