Example #1
0
 def setUp(self):
     super(ReceiveMessageAsyncTest, self).setUp()
     self.email1 = make_email_request(self.mailgun)
     self.email2 = make_email_request(self.mailgun)
     # re register callbacks as async
     self.mailgun.callback_handeler = self.mailgun.processor.async_pool
     callbacks = self.mailgun._on_attachment
     self.mailgun._on_attachment = []
     for callback in callbacks:
         self.mailgun.on_attachment(callback)
Example #2
0
 def setUp(self):
     super(ReceiveMessageAsyncTest, self).setUp()
     self.email1 = make_email_request(self.mailgun)
     self.email2 = make_email_request(self.mailgun)
     # re register callbacks as async
     self.mailgun.callback_handeler = self.mailgun.processor.async_pool
     callbacks = self.mailgun._on_attachment
     self.mailgun._on_attachment = []
     for callback in callbacks:
         self.mailgun.on_attachment(callback)
Example #3
0
    def setUp(self):
        super(ReceiveMessageCallbacksTest, self).setUp()
        self.mailgun.route('user', '/upload')

        self.email = make_email_request(self.mailgun)

        self.receve_email_mock = MagicMock(name='receve_email')
        self.attachment_mock = MagicMock(name='attachment')

        @self.mailgun.on_receive
        def receive_email_func(*args, **kwargs):
            return self.receve_email_mock(*args, **kwargs)

        import time

        @self.mailgun.on_attachment
        def attachment_func(email, attachment):
            # print "processing on", os.getpid()
            responce = self.attachment_mock(email, attachment)
            data = attachment.read()
            len(data)
            for i in range(10):
                time.sleep(0.1)

            return responce
    def test_receve_message(self):
        request = make_email_request(self.mailgun)
        # files = request.pop('files',[])
        self.mailgun.create_route('/upload')
        self.mailgun.run_async = False

        self.app.post('/upload', data=request) #, file=[request['file']])
Example #5
0
    def setUp(self):
        super(ReceiveMessageCallbacksTest, self).setUp()
        self.mailgun.route('user', '/upload')

        self.email = make_email_request(self.mailgun)

        self.receve_email_mock = MagicMock(name='receve_email')
        self.attachment_mock = MagicMock(name='attachment')

        @self.mailgun.on_receive
        def receive_email_func(*args, **kwargs):
            return self.receve_email_mock(*args, **kwargs)

        import time

        @self.mailgun.on_attachment
        def attachment_func(email, attachment):
            # print "processing on", os.getpid()
            responce = self.attachment_mock(email, attachment)
            data = attachment.read()
            len(data)
            for i in range(10):
                time.sleep(0.1)

            return responce
Example #6
0
 def test_receive_100_messages(self):
     for i in range(100):
         email = make_email_request(self.mailgun)
         response = self.appclient.post('/upload', data=email)
         self.assertEqual(response.status_code, 200)
     # self.assertEqual(self.receve_email_mock.call_count, 100)
     # self.assertEqual(self.attachment_mock.call_count, 100)
     print("received 100 emails")
Example #7
0
 def test_receive_100_messages(self):
     for i in range(100):
         email = make_email_request(self.mailgun)
         response = self.appclient.post('/upload', data=email)
         self.assertEqual(response.status_code, 200)
     # self.assertEqual(self.receve_email_mock.call_count, 100)
     # self.assertEqual(self.attachment_mock.call_count, 100)
     print ("received 100 emails")
Example #8
0
 def setUp(self):
     super(ReceiveMessageAsyncTest, self).setUp()
     self.email1 = make_email_request(self.mailgun)
     self.email2 = make_email_request(self.mailgun)
     # re register callbacks as async
     self.mailgun.callback_handeler = self.mailgun.processor. async
Example #9
0
 def test_receive_message(self):
     request = make_email_request(self.mailgun)
     # files = request.pop('files',[])
     self.mailgun.route('user', '/upload')
     response = self.appclient.post('/upload', data=request)
     self.assertEqual(response.status_code, 200)
Example #10
0
 def test_receive_message(self):
     request = make_email_request(self.mailgun)
     # files = request.pop('files',[])
     self.mailgun.route('user', '/upload')
     response = self.appclient.post('/upload', data=request)
     self.assertEqual(response.status_code, 200)