예제 #1
0
    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)
예제 #2
0
    def testDefault(self):
        """
        Test L{smtpout.FromAddress.setAsDefault} and
        L{smtpout.FromAddress.findDefault}
        """
        s = store.Store()

        addrs = dict(
            (localpart,
             smtpout.FromAddress(store=s, address=localpart + '@host'))
            for localpart in u'foo bar baz'.split())

        qux = smtpout.FromAddress(store=s, address=u'qux@host')
        qux.setAsDefault()

        self.assertEquals(
            smtpout.FromAddress.findDefault(s).address, u'qux@host')

        addrs['foo'].setAsDefault()

        self.assertEquals(
            smtpout.FromAddress.findDefault(s).address, u'foo@host')
예제 #3
0
    def testSystemAddress(self):
        """
        Test L{smtpout.FromAddress.findSystemAddress}
        """
        s = store.Store(self.mktemp())
        ls = userbase.LoginSystem(store=s)
        installOn(ls, s)

        acc = ls.addAccount('foo', 'host', 'password', protocol=u'email')
        ss = acc.avatars.open()

        fa = smtpout.FromAddress(store=ss)
        self.assertIdentical(smtpout.FromAddress.findSystemAddress(ss), fa)
        self.assertEquals(fa.address, 'foo@host')
예제 #4
0
 def setUp(self):
     """
     Install a bunch of stuff expected by L{mimebakery.createMessage}.
     """
     self.dbdir = self.mktemp()
     self.store = store.Store(self.dbdir)
     self.composer = compose.Composer(store=self.store)
     self.defaultFromAddr = smtpout.FromAddress(
         store=self.store,
         smtpHost=u'mail.example.com',
         smtpUsername=u'radix',
         smtpPassword=u'secret',
         address=u'*****@*****.**')
     self.defaultFromAddr.setAsDefault()
     da = mail.DeliveryAgent(store=self.store)
     installOn(da, self.store)
예제 #5
0
 def test_replyToAllFromAddress(self):
     """
     Test that L{xquotient.exmess.MessageDetail.replyAll} doesn't include
     addresses of L{xquotient.smtpout.FromAddress} items that exist in the
     same store as the message that is being replied to
     """
     addrs = set(
         u'blind-copy@host copy@host sender@host recipient2@host'.split())
     for addr in addrs:
         fromAddr = smtpout.FromAddress(address=addr,
                                        store=self.message.store)
         gotAddrs = set()
         for l in self.messageDetail.replyAll().recipients.itervalues():
             gotAddrs.update(e.email for e in l)
         self.assertEquals(gotAddrs, addrs - set([addr]))
         fromAddr.deleteFromStore()
예제 #6
0
    def checkNoFromAddresses(self, part):
        """
        Check that the reply addresses of C{part} don't coincide with an
        L{xquotient.smtpout.FromAddress} items in the store

        @param part: a part
        @type part: L{xquotient.mimestorage.Part}
        """
        addrs = set(
            u'blind-copy@host copy@host sender@host recipient2@host'.split())
        for addr in addrs:
            fromAddr = smtpout.FromAddress(address=addr, store=part.store)
            gotAddrs = set()
            for l in part.getAllReplyAddresses().itervalues():
                gotAddrs.update(e.email for e in l)
            self.assertEquals(gotAddrs, addrs - set([addr]))
            fromAddr.deleteFromStore()
예제 #7
0
 def setUp(self):
     self.store = store.Store()
     self.composer = MockComposer(store=self.store)
     self.composer.log = []
     self.scheduler = IScheduler(self.store)
     messageData = DummyMessageImplementation(store=self.store)
     self.message = exmess.Message.createDraft(self.store, messageData,
                                               u'test')
     self.delivery = smtpout.MessageDelivery(composer=self.composer,
                                             message=self.message,
                                             store=self.store)
     self.fromAddress = smtpout.FromAddress(store=self.store,
                                            smtpHost=u'example.org',
                                            smtpUsername=u'radix',
                                            smtpPassword=u'secret',
                                            address=u'radix@example')
     self.fromAddress.setAsDefault()
예제 #8
0
    def getFromAddressScrollTable(self):
        s = Store()

        LoginMethod(store=s,
                    internal=False,
                    protocol=u'email',
                    localpart=u'default',
                    domain=u'host',
                    verified=True,
                    account=s)

        installOn(compose.Composer(store=s), s)

        smtpout.FromAddress(store=s,
                            address=u'notdefault@host',
                            smtpHost=u'host',
                            smtpUsername=u'notdefault')

        f = smtpout.FromAddressScrollTable(s)
        f.setFragmentParent(self)
        f.docFactory = getLoader(f.fragmentName)
        return f
예제 #9
0
    def setUp(self, dbdir=None):
        self.reactor = Reactor()
        self._originalSendmail = smtpout._esmtpSendmail
        self.patch(smtpout, '_esmtpSendmail', self._esmtpSendmail)

        self.dbdir = self.mktemp()
        self.siteStore = store.Store(self.dbdir)
        Mantissa().installSite(self.siteStore, u"example.org", u"", False)

        self.userAccount = Create().addAccount(self.siteStore, u'testuser',
                                               u'example.org', u'password')
        self.userStore = self.userAccount.avatars.open()

        self.composer = compose.Composer(store=self.userStore)
        installOn(self.composer, self.userStore)

        self.defaultFromAddr = smtpout.FromAddress(
            store=self.userStore,
            smtpHost=u'mail.example.com',
            smtpUsername=u'radix',
            smtpPassword=u'secret',
            address=u'*****@*****.**')
        self.defaultFromAddr.setAsDefault()
    def _getComposeFragment(self, composeFragFactory=compose.ComposeFragment):

        s = Store()

        LoginMethod(store=s,
                    internal=False,
                    protocol=u'email',
                    localpart=u'default',
                    domain=u'host',
                    verified=True,
                    account=s)

        installOn(Inbox(store=s), s)

        smtpout.FromAddress(store=s, address=u'*****@*****.**').setAsDefault()

        composer = compose.Composer(store=s)
        installOn(composer, s)

        composeFrag = composeFragFactory(composer)
        composeFrag.jsClass = u'Quotient.Test.ComposeController'
        composeFrag.setFragmentParent(self)
        composeFrag.docFactory = getLoader(composeFrag.fragmentName)
        return (s, composeFrag)
예제 #11
0
 def setUpMailStuff(self):
     mr = PersistenceMixin.setUpMailStuff(self)
     smtpout.FromAddress(store=mr.store, address=u'recipient@host')
     return mr