Пример #1
0
 def test_api_key_on_send(self, mock_request):
     mock_request.return_value = self.mock_response('')
     msg = Message(to='me', text='hi')
     sender = Sender(message=msg)
     url = sender._get_api_url(secure=True)
     data = msg.json()
     headers = sender._get_headers(api_key=POSTMARK_API_TEST_KEY)
     sender.send(api_key=POSTMARK_API_TEST_KEY)
     mock_request.assert_called_with('POST', url, data=data,
                                     headers=headers)
Пример #2
0
 def test_api_key_on_send(self, mock_request):
     mock_request.return_value = self.mock_response('')
     msg = Message(to='me', text='hi')
     sender = Sender(message=msg)
     url = sender._get_api_url(secure=True)
     data = msg.json()
     headers = sender._get_headers(api_key=POSTMARK_API_TEST_KEY)
     sender.send(api_key=POSTMARK_API_TEST_KEY)
     mock_request.assert_called_with('POST', url, data=data,
                                     headers=headers)
Пример #3
0
 def _test_secure_overrides(self, mock_request, init_secure=None,
                            send_secure=None):
     mock_request.return_value = self.mock_response('')
     msg = Message(to='me', text='hi')
     sender = Sender(test=True, secure=init_secure)
     if init_secure or init_secure is None:
         url = POSTMARK_API_URL_SECURE
     else:
         url = POSTMARK_API_URL
     if not send_secure and send_secure is not None:
         url = POSTMARK_API_URL
     elif send_secure:
         url = POSTMARK_API_URL_SECURE
     url = urljoin(url, Sender.endpoint)
     data = msg.json()
     headers = sender._get_headers(api_key=POSTMARK_API_TEST_KEY)
     sender.send(secure=send_secure, message=msg)
     mock_request.assert_called_with('POST', url, data=data,
                                     headers=headers)
Пример #4
0
 def _test_secure_overrides(self, mock_request, init_secure=None,
                            send_secure=None):
     mock_request.return_value = self.mock_response('')
     msg = Message(to='me', text='hi')
     sender = Sender(test=True, secure=init_secure)
     if init_secure or init_secure is None:
         url = POSTMARK_API_URL_SECURE
     else:
         url = POSTMARK_API_URL
     if not send_secure and send_secure is not None:
         url = POSTMARK_API_URL
     elif send_secure:
         url = POSTMARK_API_URL_SECURE
     url = urljoin(url, Sender.endpoint)
     data = msg.json()
     headers = sender._get_headers(api_key=POSTMARK_API_TEST_KEY)
     sender.send(secure=send_secure, message=msg)
     mock_request.assert_called_with('POST', url, data=data,
                                     headers=headers)