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


Python Mail.add_section方法代碼示例

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


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

示例1: test_send

# 需要導入模塊: from sendgrid import Mail [as 別名]
# 或者: from sendgrid.Mail import add_section [as 別名]
 def test_send(self):
     m = Mail()
     m.add_to('John, Doe <[email protected]>')
     m.set_subject('test')
     m.set_html('WIN')
     m.set_text('WIN')
     m.set_from('[email protected]')
     m.set_asm_group_id(42)
     m.add_cc('[email protected]')
     m.add_bcc('[email protected]')
     m.add_substitution('subKey', 'subValue')
     m.add_section('testSection', 'sectionValue')
     m.add_category('testCategory')
     m.add_unique_arg('testUnique', 'uniqueValue')
     m.add_filter('testFilter', 'filter', 'filterValue')
     m.add_attachment_stream('testFile', 'fileValue')
     url = self.sg._build_body(m)
     url.pop('api_key', None)
     url.pop('api_user', None)
     url.pop('date', None)
     test_url = json.loads('''
         {
             "to[]": ["[email protected]"],
             "toname[]": ["John Doe"],
             "html": "WIN",
             "text": "WIN",
             "subject": "test",
             "files[testFile]": "fileValue",
             "from": "[email protected]",
             "cc[]": ["[email protected]"],
             "bcc[]": ["[email protected]"]
         }
         ''')
     test_url['x-smtpapi'] = json.dumps(json.loads('''
         {
             "sub": {
                 "subKey": ["subValue"]
             },
             "section": {
                 "testSection":"sectionValue"
             },
             "category": ["testCategory"],
             "unique_args": {
                 "testUnique":"uniqueValue"
             },
             "filters": {
                 "testFilter": {
                     "settings": {
                         "filter": "filterValue"
                     }
                 }
             },
             "asm_group_id": 42
         }
         '''))
     
     try:
         self.assertItemsEqual(url, test_url)
     except: # Python 3+
         self.assertCountEqual(url, test_url)
開發者ID:Adomako-Bismark,項目名稱:sendgrid-python,代碼行數:62,代碼來源:test_mail_v2.py

示例2: test_send

# 需要導入模塊: from sendgrid import Mail [as 別名]
# 或者: from sendgrid.Mail import add_section [as 別名]
 def test_send(self):
   m = Mail()
   m.add_to('John, Doe <[email protected]>')
   m.set_subject('test')
   m.set_html('WIN')
   m.set_text('WIN')
   m.set_from('[email protected]')
   m.add_substitution('subKey', 'subValue')
   m.add_section('testSection', 'sectionValue')
   m.add_category('testCategory')
   m.add_unique_arg('testUnique', 'uniqueValue')
   m.add_filter('testFilter', 'filter', 'filterValue')
   m.add_attachment_stream('testFile', 'fileValue')
   self.sg.send(m)
   url = self.sg._build_body(m)
   url.pop('api_key', None)
   url.pop('api_user', None)
   url.pop('date', None)
   testUrl = json.loads('''{"to[]": ["[email protected]"],
   "toname[]": ["John Doe"],
   "html": "WIN",
   "text": "WIN",
   "subject": "test",
   "files[testFile]": "fileValue",
   "from": "[email protected]",
   "headers": "",
   "fromname": "",
   "replyto": ""}''')
   testUrl['x-smtpapi'] = json.dumps(json.loads('''{"sub":{"subKey":["subValue"]},
     "section":{"testSection":"sectionValue"},
     "category":["testCategory"],
     "unique_args":{"testUnique":"uniqueValue"},
     "filters":{"testFilter":{"settings":{"filter":"filterValue"}}}}'''))
   self.assertEqual(url, testUrl)
開發者ID:miphreal,項目名稱:sendgrid-python,代碼行數:36,代碼來源:__init__.py

示例3: test_send

# 需要導入模塊: from sendgrid import Mail [as 別名]
# 或者: from sendgrid.Mail import add_section [as 別名]
 def test_send(self):
     m = Mail()
     m.add_to("John, Doe <[email protected]>")
     m.set_subject("test")
     m.set_html("WIN")
     m.set_text("WIN")
     m.set_from("[email protected]")
     m.add_substitution("subKey", "subValue")
     m.add_section("testSection", "sectionValue")
     m.add_category("testCategory")
     m.add_unique_arg("testUnique", "uniqueValue")
     m.add_filter("testFilter", "filter", "filterValue")
     m.add_attachment_stream("testFile", "fileValue")
     url = self.sg._build_body(m)
     url.pop("api_key", None)
     url.pop("api_user", None)
     url.pop("date", None)
     test_url = json.loads(
         """
         {
             "to[]": ["[email protected]"],
             "toname[]": ["John Doe"],
             "html": "WIN",
             "text": "WIN",
             "subject": "test",
             "files[testFile]": "fileValue",
             "from": "[email protected]"
         }
         """
     )
     test_url["x-smtpapi"] = json.dumps(
         json.loads(
             """
         {
             "to" : ["John, Doe <[email protected]>"],
             "sub": {
                 "subKey": ["subValue"]
             },
             "section": {
                 "testSection":"sectionValue"
             },
             "category": ["testCategory"],
             "unique_args": {
                 "testUnique":"uniqueValue"
             },
             "filters": {
                 "testFilter": {
                     "settings": {
                         "filter": "filterValue"
                     }
                 }
             }
         }
         """
         )
     )
     self.assertEqual(url, test_url)
開發者ID:RekindleInc,項目名稱:sendgrid-python,代碼行數:59,代碼來源:__init__.py


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