Beispiel #1
0
    def handle_invoice(self, datetime, file_name, mail_id):
        mail_stub = self.get_stub(datetime, file_name)

        MailHepls.get_mails = Mock(return_value=(
            ProviderTestSuite.EMAIL, {ProviderTestSuite.EMAIL: [mail_stub]}))
        MailInvoiceService.get_count_new_mails = Mock(return_value=1)
        MailInvoiceService.handle_mail()

        resp = self.client.post(
            "/api/mail/" + str(mail_id), data=self._serialize({
                'action': 'R',
                'index': 0
            }), headers=self._get_headers(True))

        return resp
Beispiel #2
0
 def post(self):
     """
     Запрос на обработку почтового ящика(проверка новых писем и сохранение
     их в БД).
     """
     from services.mailinvoice import MailInvoiceService, \
         MailInvoiceException
     try:
         res = MailInvoiceService.handle_mail()
     except MailInvoiceException as err:
         error(unicode(err))
         abort(400, message=unicode(err))
     res = 'ok' if len(res) else 'nothing'
     return res