예제 #1
0
    def test_raises_error_when_adding_mails_not_allowed(self):
        dossier = create(Builder("dossier"))
        dossier.manage_permission('ftw.mail: Add Inbound Mail',
                                  roles=[], acquire=False)
        to_addess = IEmailAddress(self.request).get_email_for_object(dossier)
        message = self.MAIL_TEMPLATE.format(to_addess)

        with self.assertRaises(Unauthorized):
            inbound.createMailInContainer(dossier, message)
예제 #2
0
    def test_raises_error_when_adding_mails_not_allowed(self):
        dossier = create(Builder("dossier"))
        dossier.manage_permission('ftw.mail: Add Inbound Mail',
                                  roles=[],
                                  acquire=False)
        to_addess = IEmailAddress(self.request).get_email_for_object(dossier)
        message = self.MAIL_TEMPLATE.format(to_addess)

        with self.assertRaises(Unauthorized):
            inbound.createMailInContainer(dossier, message)
예제 #3
0
    def test_raises_error_when_mail_not_in_addable_types(self):
        ttool = api.portal.get_tool('portal_types')
        dossier_fti = ttool.get('opengever.dossier.businesscasedossier')
        dossier_fti.allowed_content_types = tuple()

        dossier = create(Builder("dossier"))
        to_addess = IEmailAddress(self.request).get_email_for_object(dossier)
        message = self.MAIL_TEMPLATE.format(to_addess)

        with self.assertRaises(ValueError):
            inbound.createMailInContainer(dossier, message)
예제 #4
0
    def test_raises_error_when_mail_not_in_addable_types(self):
        ttool = api.portal.get_tool('portal_types')
        dossier_fti = ttool.get('opengever.dossier.businesscasedossier')
        dossier_fti.allowed_content_types = tuple()

        dossier = create(Builder("dossier"))
        to_addess = IEmailAddress(self.request).get_email_for_object(dossier)
        message = self.MAIL_TEMPLATE.format(to_addess)

        with self.assertRaises(ValueError):
            inbound.createMailInContainer(dossier, message)
예제 #5
0
 def file_sent_mail_in_dossier(self, msg):
     dossier = self.context
     mail = createMailInContainer(dossier, msg.as_string())
     mail.delivery_date = date.today()
     mail.reindexObject(idxs=['delivery_date'])
     status_msg = _(u"Sent mail filed as '${title}'.",
                    mapping={'title': mail.title_or_id()})
     IStatusMessage(self.request).addStatusMessage(status_msg, type='info')
예제 #6
0
 def file_sent_mail_in_dossier(self, msg):
     dossier = self.context
     mail = createMailInContainer(dossier, msg.as_string())
     mail.delivery_date = date.today()
     mail.reindexObject(idxs=['delivery_date'])
     status_msg = _(
         u"Sent mail filed as '${title}'.",
         mapping={'title': mail.title_or_id()})
     IStatusMessage(self.request).addStatusMessage(status_msg, type='info')
예제 #7
0
    def test_mail_creation(self):
        dossier = create(Builder("dossier"))
        to_addess = IEmailAddress(self.request).get_email_for_object(dossier)

        message = self.MAIL_TEMPLATE.format(to_addess)
        obj = inbound.createMailInContainer(dossier, message)
        self.assertTrue(obj.preserved_as_paper)
        self.assertEqual(message, obj.message.data)
        self.assertEqual(MESSAGE_SOURCE_MAILIN, obj.message_source)
예제 #8
0
    def test_mail_creation(self):
        dossier = create(Builder("dossier"))
        to_addess = IEmailAddress(self.request).get_email_for_object(dossier)

        message = self.MAIL_TEMPLATE.format(to_addess)
        obj = inbound.createMailInContainer(dossier, message)
        self.assertTrue(obj.preserved_as_paper)
        self.assertEqual(message, obj.message.data)
        self.assertEqual(MESSAGE_SOURCE_MAILIN, obj.message_source)
예제 #9
0
    def test_p7m_mail_creation(self):
        dossier = create(Builder("dossier"))
        to_address = IEmailAddress(self.request).get_email_for_object(dossier)

        msg = email.message_from_string(load('signed.p7m'))
        msg.replace_header('To', to_address)
        message = msg.as_string()

        obj = inbound.createMailInContainer(dossier, message)
        self.assertTrue(obj.preserved_as_paper)
        self.assertEqual(message, obj.message.data)
        self.assertEqual(MESSAGE_SOURCE_MAILIN, obj.message_source)
        self.assertEqual('Hello.p7m', obj.message.filename)
        self.assertEqual('application/pkcs7-mime', obj.message.contentType)
예제 #10
0
 def create_mail_inbound(self):
     dossier = create(Builder("dossier"))
     mail = inbound.createMailInContainer(dossier, MAIL_DATA)
     return mail
 def create_mail_inbound(self):
     dossier = create(Builder("dossier"))
     mail = inbound.createMailInContainer(dossier, MAIL_DATA)
     return mail
 def test_message_filename_initialzed_with_inboud_mail(self):
     dossier = create(Builder("dossier"))
     mail = inbound.createMailInContainer(dossier, MAIL_DATA)
     self.assertEquals('die-burgschaft.eml', mail.message.filename)