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)
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)
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')
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')
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)
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)
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)