當前位置: 首頁>>代碼示例>>Python>>正文


Python Message.attach_binary方法代碼示例

本文整理匯總了Python中pystmark.Message.attach_binary方法的典型用法代碼示例。如果您正苦於以下問題:Python Message.attach_binary方法的具體用法?Python Message.attach_binary怎麽用?Python Message.attach_binary使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pystmark.Message的用法示例。


在下文中一共展示了Message.attach_binary方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_attach_binary

# 需要導入模塊: from pystmark import Message [as 別名]
# 或者: from pystmark.Message import attach_binary [as 別名]
 def test_attach_binary(self):
     msg = Message(to='me', text='hi')
     data = urandom(64)
     name = 'test.pdf'
     msg.attach_binary(data, name)
     attachment = {
         'Content': b64encode(data).decode('utf-8'),
         'ContentType': 'application/pdf',
         'Name': name
     }
     self.assertEqual(msg.attachments, [attachment])
開發者ID:jdavisp3,項目名稱:pystmark,代碼行數:13,代碼來源:test_pystmark.py

示例2: test_attach_binary_content_type_override

# 需要導入模塊: from pystmark import Message [as 別名]
# 或者: from pystmark.Message import attach_binary [as 別名]
 def test_attach_binary_content_type_override(self):
     msg = Message(to='me', text='hi')
     data = urandom(64)
     content_type = 'xcascasc'
     name = 'test.pdf'
     msg.attach_binary(data, name, content_type=content_type)
     attachment = {
         'Content': b64encode(data).decode('utf-8'),
         'ContentType': content_type,
         'Name': name
     }
     self.assertEqual(msg.attachments, [attachment])
開發者ID:jdavisp3,項目名稱:pystmark,代碼行數:14,代碼來源:test_pystmark.py

示例3: test_attach_binary_default_content_type

# 需要導入模塊: from pystmark import Message [as 別名]
# 或者: from pystmark.Message import attach_binary [as 別名]
 def test_attach_binary_default_content_type(self, mock_type):
     mock_type.return_value = 'application/octet-stream'
     msg = Message(to='me', text='hi')
     data = urandom(64)
     name = 'test.bin'
     msg.attach_binary(data, name)
     attachment = {
         'Content': b64encode(data).decode('utf-8'),
         'ContentType': 'application/octet-stream',
         'Name': name
     }
     self.assertEqual(msg.attachments, [attachment])
開發者ID:jdavisp3,項目名稱:pystmark,代碼行數:14,代碼來源:test_pystmark.py

示例4: test_attach_binary_with_content_id

# 需要導入模塊: from pystmark import Message [as 別名]
# 或者: from pystmark.Message import attach_binary [as 別名]
 def test_attach_binary_with_content_id(self):
     msg = Message(to='me', text='hi')
     data = urandom(64)
     name = 'test.pdf'
     content_type = 'image/png'
     content_id = 'cid:{0}@example.com'.format(uuid.uuid4())
     msg.attach_binary(data, name, content_type=content_type,
                       content_id=content_id)
     attachment = {
         'Content': b64encode(data).decode('utf-8'),
         'ContentType': 'image/png',
         'Name': name,
         'ContentID': content_id
     }
     self.assertEqual(msg.attachments, [attachment])
開發者ID:muravjov,項目名稱:pystmark,代碼行數:17,代碼來源:test_pystmark.py

示例5: test_attach_binary_no_content_id

# 需要導入模塊: from pystmark import Message [as 別名]
# 或者: from pystmark.Message import attach_binary [as 別名]
 def test_attach_binary_no_content_id(self):
     msg = Message(to='me', text='hi')
     data = urandom(64)
     name = 'test.pdf'
     msg.attach_binary(data, name)
     self.assertEqual('ContentID' in msg.attachments[0], False)
開發者ID:muravjov,項目名稱:pystmark,代碼行數:8,代碼來源:test_pystmark.py


注:本文中的pystmark.Message.attach_binary方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。