Пример #1
0
 def test_post(self):
   request = webapp2.Request.blank('/mail', POST={
       'to': 'to', 'from': 'from', 'cc': 'cc', 'subject': 'subject',
       'body': 'body'})
   response = webapp2.Response()
   handler = mail_request_handler.MailRequestHandler(request, response)
   self.mox.StubOutWithMock(handler, '_send_email')
   handler._send_email('to', 'from', 'cc', 'subject', 'body')
   self.mox.ReplayAll()
   handler.post()
   self.mox.VerifyAll()
Пример #2
0
 def test_send_email(self):
   response = webapp2.Response()
   handler = mail_request_handler.MailRequestHandler(None, response)
   message = object()
   self.mox.StubOutWithMock(handler, '_send')
   self.mox.StubOutWithMock(handler, '_generate_email')
   handler._generate_email('to', 'from', 'cc', 'subject', 'body').AndReturn(
       message)
   handler._send('/_ah/mail/to', message).AndReturn(
       dispatcher.ResponseTuple('500 Internal Server Error', [], 'Response'))
   self.mox.ReplayAll()
   handler._send_email('to', 'from', 'cc', 'subject', 'body')
   self.mox.VerifyAll()
   self.assertEqual(500, response.status_int)
Пример #3
0
 def test_send(self):
     self.mox.StubOutWithMock(mail_request_handler.MailRequestHandler,
                              'dispatcher')
     handler = mail_request_handler.MailRequestHandler(None, None)
     handler.dispatcher = self.mox.CreateMock(dispatcher.Dispatcher)
     handler.dispatcher.add_request(method='POST',
                                    relative_url='URL',
                                    headers=[('Content-Type',
                                              'message/rfc822')],
                                    body='mail message',
                                    source_ip='0.1.0.20')
     message = self.mox.CreateMock(email.message.Message)
     message.as_string().AndReturn('mail message')
     self.mox.ReplayAll()
     handler._send('URL', message)
     self.mox.VerifyAll()