Beispiel #1
0
def createDatabase(store):
    """
    Make a L{Person} in the given store.
    """
    organizer = Organizer(store=store)
    person = Person(store=store, organizer=organizer, name=NAME)
    person.created = CREATED
Beispiel #2
0
def createDatabase(store):
    """
    Make a L{Person} in the given store.
    """
    organizer = Organizer(store=store)
    person = Person(store=store, organizer=organizer, name=NAME)
    person.created = CREATED
 def test_getPeople(self):
     """
     L{Inbox.getPeople} should return all L{Person} items in the store,
     sorted in the naive alphabetical way.
     """
     organizer = Organizer(store=self.store)
     installOn(organizer, self.store)
     organizer.storeOwnerPerson.name = u'Carol'
     bob = Person(store=self.store, organizer=organizer, name=u'Bob')
     self.assertEquals(list(self.inbox.getPeople()),
                       [bob, organizer.storeOwnerPerson])
Beispiel #4
0
def createDatabase(s):
    imgfile = FilePath(__file__).parent().parent().child('resources').child(
        'square.png')
    outfile = s.newFile('the-image')
    outfile.write(imgfile.getContent())
    outfile.close()

    Mugshot(store=s,
            person=Person(store=s, name=u'Bob'),
            body=outfile.finalpath,
            type=u'image/png')
Beispiel #5
0
 def test_upgradeCorrespondents(self):
     """
     Verify that Correspondent items are created for each incoming message,
     so that 'view from person' still works.
     """
     ms = MailboxSelector(self.store)
     newPerson = Person(store=self.store, name=u'test bob')
     PersonEmailAddress(store=self.store,
                        person=newPerson,
                        address=u'*****@*****.**')
     ms.refineByPerson(newPerson)
     # As it currently stands, outgoing and draft messages are both not
     # considered for the addition of Correspondent items.  This might not
     # be correct, but it is the current behavior and at the time of writing
     # this test the goal was to ensure that the behavior would not change
     # across this upgrade.  -glyph
     self.assertMessageQuery(ms, [0, 1, 2, 5, 6, 7])
Beispiel #6
0
def createDatabase(store):
    """
    Make L{Person} and L{Mugshot} items.  Set the C{body} and C{smallerBody}
    attributes of the L{Mugshot} item to point at a copy of
    I{xmantissa/test/resources/square.png} beneath the store's directory.
    """
    atomicImageFile = store.newFile(*MUGSHOT_BODY_PATH_SEGMENTS)
    imageFilePath = FilePath(__file__).parent().parent().child(
        'resources').child('square.png')
    atomicImageFile.write(imageFilePath.getContent())
    atomicImageFile.close()

    Mugshot(store=store,
            person=Person(store=store),
            body=atomicImageFile.finalpath,
            smallerBody=atomicImageFile.finalpath,
            type=MUGSHOT_TYPE)
Beispiel #7
0
    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 setUp(self):
        """
        Extend L{_MessageRetrievalMixin.setUp} to also install an
        L{Organizer}, L{Person} and L{EmailAddress}, and an L{Message} from
        that person
        """
        super(MessagesByPersonRetrievalTestCase, self).setUp()

        self.organizer = Organizer(store=self.store)
        installOn(self.organizer, self.store)

        self.person = Person(store=self.store,
                             organizer=self.organizer,
                             name=u'The Person')

        EmailAddress(store=self.store,
                     address=u'the@person',
                     person=self.person)

        self.messageFromPerson = testMessageFactory(store=self.store,
                                                    read=False,
                                                    spam=False,
                                                    receivedWhen=Time(),
                                                    sender=u'the@person')
def createDatabase(store):
    """
    Make a L{Person} with a corresponding L{RealName} which will be deleted.
    """
    person = Person(store=store)
    name = RealName(store=store, person=person)
 def makePerson(name, address):
     return EmailAddress(store=s,
                         address=address,
                         person=Person(store=s,
                                       organizer=o,
                                       name=name)).person
Beispiel #11
0
def createDatabase(s):
    EmailAddress(store=s,
                 address=u'*****@*****.**',
                 type=u'default',
                 person=Person(store=s,
                               name=u'Bob'))
def createDatabase(s):
    PhoneNumber(store=s,
                number=u'555-1212',
                type=u'default',
                person=Person(store=s,
                              name=u'Bob'))
    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 makePerson(email, name):
     EmailAddress(store=s,
                  address=email,
                  person=Person(store=s, name=name))