本文整理匯總了Python中pystmark.Message.json方法的典型用法代碼示例。如果您正苦於以下問題:Python Message.json方法的具體用法?Python Message.json怎麽用?Python Message.json使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pystmark.Message
的用法示例。
在下文中一共展示了Message.json方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_api_key_on_send
# 需要導入模塊: from pystmark import Message [as 別名]
# 或者: from pystmark.Message import json [as 別名]
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: _test_secure_overrides
# 需要導入模塊: from pystmark import Message [as 別名]
# 或者: from pystmark.Message import json [as 別名]
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)