@@ -56,7 +56,7 @@ def test_mandrill_compat_email_send(self, mock_client):
5656 html = '<h2>html</h2>'
5757 )
5858
59- self .assertEqual (json .dumps (self .mail .get (), sort_keys = True ), '{"content": [{"type": "text/html", "value": "<h2>html</h2>"}], "from": {"email ": "from"}, "personalizations": [{"to": [{"email": "test@example.com"}]}], "subject": "Subject"}' )
59+ self .assertEqual (json .dumps (self .mail .get (), sort_keys = True ), '{"content": [{"type": "text/html", "value": "<h2>html</h2>"}], "from": {"name ": "from"}, "personalizations": [{"to": [{"email": "test@example.com"}]}], "subject": "Subject"}' )
6060
6161 @patch ('python_http_client.Client._make_request' )
6262 def test_mandrill_compat_single_recipient (self , mock_client ):
@@ -70,7 +70,7 @@ def test_mandrill_compat_single_recipient(self, mock_client):
7070 html = '<h2>html</h2>'
7171 )
7272
73- self .assertEqual (json .dumps (self .mail .get (), sort_keys = True ), '{"content": [{"type": "text/html", "value": "<h2>html</h2>"}], "from": {"email ": "from"}, "personalizations": [{"to": [{"email": "test@example.com"}]}], "subject": "Subject"}' )
73+ self .assertEqual (json .dumps (self .mail .get (), sort_keys = True ), '{"content": [{"type": "text/html", "value": "<h2>html</h2>"}], "from": {"name ": "from"}, "personalizations": [{"to": [{"email": "test@example.com"}]}], "subject": "Subject"}' )
7474
7575 @patch ('python_http_client.Client._make_request' )
7676 def test_mandrill_compat_multiple_recipient (self , mock_client ):
@@ -84,7 +84,7 @@ def test_mandrill_compat_multiple_recipient(self, mock_client):
8484 html = '<h2>html</h2>'
8585 )
8686
87- self .assertEqual (json .dumps (self .mail .get (), sort_keys = True ), '{"content": [{"type": "text/html", "value": "<h2>html</h2>"}], "from": {"email ": "from"}, "personalizations": [{"to": [{"email": "test1@example.com"}, {"email": "test2@example.com"}]}], "subject": "Subject"}' )
87+ self .assertEqual (json .dumps (self .mail .get (), sort_keys = True ), '{"content": [{"type": "text/html", "value": "<h2>html</h2>"}], "from": {"name ": "from"}, "personalizations": [{"to": [{"email": "test1@example.com"}, {"email": "test2@example.com"}]}], "subject": "Subject"}' )
8888
8989 @patch ('python_http_client.Client._make_request' )
9090 def test_single_recipient_email_object (self , mock_client ):
@@ -98,7 +98,7 @@ def test_single_recipient_email_object(self, mock_client):
9898 html = '<h2>html</h2>'
9999 )
100100
101- self .assertEqual (json .dumps (self .mail .get (), sort_keys = True ), '{"content": [{"type": "text/html", "value": "<h2>html</h2>"}], "from": {"email ": "from"}, "personalizations": [{"to": [{"email": "test1@example.com"}]}], "subject": "Subject"}' )
101+ self .assertEqual (json .dumps (self .mail .get (), sort_keys = True ), '{"content": [{"type": "text/html", "value": "<h2>html</h2>"}], "from": {"name ": "from"}, "personalizations": [{"to": [{"email": "test1@example.com"}]}], "subject": "Subject"}' )
102102
103103 @patch ('python_http_client.Client._make_request' )
104104 def test_multiple_recipient_email_object (self , mock_client ):
@@ -112,7 +112,7 @@ def test_multiple_recipient_email_object(self, mock_client):
112112 html = '<h2>html</h2>'
113113 )
114114
115- self .assertEqual (json .dumps (self .mail .get (), sort_keys = True ), '{"content": [{"type": "text/html", "value": "<h2>html</h2>"}], "from": {"email ": "from"}, "personalizations": [{"to": [{"email": "test1@example.com"}, {"email": "test2@example.com"}]}], "subject": "Subject"}' )
115+ self .assertEqual (json .dumps (self .mail .get (), sort_keys = True ), '{"content": [{"type": "text/html", "value": "<h2>html</h2>"}], "from": {"name ": "from"}, "personalizations": [{"to": [{"email": "test1@example.com"}, {"email": "test2@example.com"}]}], "subject": "Subject"}' )
116116
117117 @patch ('python_http_client.Client._make_request' )
118118 def test_hello_email (self , mock_client ):
@@ -124,9 +124,8 @@ def test_hello_email(self, mock_client):
124124
125125 """Minimum required to send an email"""
126126
127- self .mail .set_from (Email ("test@example.com" ))
128-
129- self .mail .set_subject ("Hello World from the SendGrid Python Library" )
127+ self .mail .from_email = Email ("test@example.com" )
128+ self .mail .subject = "Hello World from the SendGrid Python Library"
130129
131130 personalization = Personalization ()
132131 personalization .add_to (Email ("test@example.com" ))
@@ -147,9 +146,9 @@ def test_kitchenSink(self, mock_client):
147146
148147 """All settings set"""
149148
150- self .mail .set_from ( Email ("test@example.com" , "Example User" ) )
149+ self .mail .from_email = Email ("test@example.com" , "Example User" )
151150
152- self .mail .set_subject ( "Hello World from the SendGrid Python Library" )
151+ self .mail .subject = "Hello World from the SendGrid Python Library"
153152
154153 personalization = Personalization ()
155154 personalization .add_to (Email ("test@example.com" , "Example User" ))
@@ -158,14 +157,14 @@ def test_kitchenSink(self, mock_client):
158157 personalization .add_cc (Email ("test@example.com" , "Example User" ))
159158 personalization .add_bcc (Email ("test@example.com" ))
160159 personalization .add_bcc (Email ("test@example.com" ))
161- personalization .set_subject ( "Hello World from the Personalized SendGrid Python Library" )
160+ personalization .subject = "Hello World from the Personalized SendGrid Python Library"
162161 personalization .add_header (Header ("X-Test" , "test" ))
163162 personalization .add_header (Header ("X-Mock" , "true" ))
164163 personalization .add_substitution (Substitution ("%name%" , "Example User" ))
165164 personalization .add_substitution (Substitution ("%city%" , "Denver" ))
166165 personalization .add_custom_arg (CustomArg ("user_id" , "343" ))
167166 personalization .add_custom_arg (CustomArg ("type" , "marketing" ))
168- personalization .set_send_at ( 1443636843 )
167+ personalization .send_at = 1443636843
169168 self .mail .add_personalization (personalization )
170169
171170 personalization2 = Personalization ()
@@ -175,36 +174,36 @@ def test_kitchenSink(self, mock_client):
175174 personalization2 .add_cc (Email ("test@example.com" , "Example User" ))
176175 personalization2 .add_bcc (Email ("test@example.com" ))
177176 personalization2 .add_bcc (Email ("test@example.com" ))
178- personalization2 .set_subject ( "Hello World from the Personalized SendGrid Python Library" )
177+ personalization2 .subject = "Hello World from the Personalized SendGrid Python Library"
179178 personalization2 .add_header (Header ("X-Test" , "test" ))
180179 personalization2 .add_header (Header ("X-Mock" , "true" ))
181180 personalization2 .add_substitution (Substitution ("%name%" , "Example User" ))
182181 personalization2 .add_substitution (Substitution ("%city%" , "Denver" ))
183182 personalization2 .add_custom_arg (CustomArg ("user_id" , "343" ))
184183 personalization2 .add_custom_arg (CustomArg ("type" , "marketing" ))
185- personalization2 .set_send_at ( 1443636843 )
184+ personalization2 .send_at = 1443636843
186185 self .mail .add_personalization (personalization2 )
187186
188187 self .mail .add_content (Content ("text/plain" , "some text here" ))
189188 self .mail .add_content (Content ("text/html" , "<html><body>some text here</body></html>" ))
190189
191190 attachment = Attachment ()
192- attachment .set_content ( "TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVyIGFkaXBpc2NpbmcgZWxpdC4gQ3JhcyBwdW12" )
193- attachment .set_type ( "application/pdf" )
194- attachment .set_filename ( "balance_001.pdf" )
195- attachment .set_disposition ( "attachment" )
196- attachment .set_content_id ( "Balance Sheet" )
191+ attachment .content = "TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVyIGFkaXBpc2NpbmcgZWxpdC4gQ3JhcyBwdW12"
192+ attachment .type = "application/pdf"
193+ attachment .filename = "balance_001.pdf"
194+ attachment .disposition = "attachment"
195+ attachment .content_id = "Balance Sheet"
197196 self .mail .add_attachment (attachment )
198197
199198 attachment2 = Attachment ()
200- attachment2 .set_content ( "BwdW" )
201- attachment2 .set_type ( "image/png" )
202- attachment2 .set_filename ( "banner.png" )
203- attachment2 .set_disposition ( "inline" )
204- attachment2 .set_content_id ( "Banner" )
199+ attachment2 .content = "BwdW"
200+ attachment2 .type = "image/png"
201+ attachment2 .filename = "banner.png"
202+ attachment2 .disposition = "inline"
203+ attachment2 .content_id = "Banner"
205204 self .mail .add_attachment (attachment2 )
206205
207- self .mail .set_template_id ( "13b8f94f-bcae-4ec6-b752-70d6cb59f932" )
206+ self .mail .template_id = "13b8f94f-bcae-4ec6-b752-70d6cb59f932"
208207
209208 self .mail .add_section (Section ("%section1%" , "Substitution Text for Section 1" ))
210209 self .mail .add_section (Section ("%section2%" , "Substitution Text for Section 2" ))
@@ -220,29 +219,29 @@ def test_kitchenSink(self, mock_client):
220219 self .mail .add_custom_arg (CustomArg ("campaign" , "welcome" ))
221220 self .mail .add_custom_arg (CustomArg ("weekday" , "morning" ))
222221
223- self .mail .set_send_at ( 1443636842 )
222+ self .mail .send_at = 1443636842
224223
225- self .mail .set_batch_id ( "sendgrid_batch_id" )
224+ self .mail .batch_id = "sendgrid_batch_id"
226225
227- self .mail .set_asm ( ASM (99 , [4 , 5 , 6 , 7 , 8 ]) )
226+ self .mail .asm = ASM (99 , [4 , 5 , 6 , 7 , 8 ])
228227
229- self .mail .set_ip_pool_name ( "24" )
228+ self .mail .ip_pool_name = "24"
230229
231230 mail_settings = MailSettings ()
232- mail_settings .set_bcc_settings ( BCCSettings (True , Email ("test@example.com" ) ))
233- mail_settings .set_bypass_list_management ( BypassListManagement (True ) )
234- mail_settings .set_footer_settings ( FooterSettings (True , "Footer Text" , "<html><body>Footer Text</body></html>" ) )
235- mail_settings .set_sandbox_mode ( SandBoxMode (True ) )
236- mail_settings .set_spam_check ( SpamCheck (True , 1 , "https://spamcatcher.sendgrid.com" ) )
237- self .mail .set_mail_settings ( mail_settings )
231+ mail_settings .bcc_settings = BCCSettings (True , Email ("test@example.com" ))
232+ mail_settings .bypass_list_management = BypassListManagement (True )
233+ mail_settings .footer_settings = FooterSettings (True , "Footer Text" , "<html><body>Footer Text</body></html>" )
234+ mail_settings .sandbox_mode = SandBoxMode (True )
235+ mail_settings .spam_check = SpamCheck (True , 1 , "https://spamcatcher.sendgrid.com" )
236+ self .mail .mail_settings = mail_settings
238237
239238 tracking_settings = TrackingSettings ()
240- tracking_settings .set_click_tracking ( ClickTracking (True , True ) )
241- tracking_settings .set_open_tracking ( OpenTracking (True , "Optional tag to replace with the open image in the body of the message" ) )
242- tracking_settings .set_subscription_tracking ( SubscriptionTracking (True , "text to insert into the text/plain portion of the message" , "<html><body>html to insert into the text/html portion of the message</body></html>" , "Optional tag to replace with the open image in the body of the message" ) )
243- tracking_settings .set_ganalytics ( Ganalytics (True , "some source" , "some medium" , "some term" , "some content" , "some campaign" ) )
244- self .mail .set_tracking_settings ( tracking_settings )
239+ tracking_settings .click_tracking = ClickTracking (True , True )
240+ tracking_settings .open_tracking = OpenTracking (True , "Optional tag to replace with the open image in the body of the message" )
241+ tracking_settings .subscription_tracking = SubscriptionTracking (True , "text to insert into the text/plain portion of the message" , "<html><body>html to insert into the text/html portion of the message</body></html>" , "Optional tag to replace with the open image in the body of the message" )
242+ tracking_settings .ganalytics = Ganalytics (True , "some source" , "some medium" , "some term" , "some content" , "some campaign" )
243+ self .mail .tracking_settings = tracking_settings
245244
246- self .mail .set_reply_to ( Email ("test@example.com" ) )
245+ self .mail .reply_to = Email ("test@example.com" )
247246
248247 self .assertEqual (json .dumps (self .mail .get (), sort_keys = True ), '{"asm": {"group_id": 99, "groups_to_display": [4, 5, 6, 7, 8]}, "attachments": [{"content": "TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVyIGFkaXBpc2NpbmcgZWxpdC4gQ3JhcyBwdW12", "content_id": "Balance Sheet", "disposition": "attachment", "filename": "balance_001.pdf", "type": "application/pdf"}, {"content": "BwdW", "content_id": "Banner", "disposition": "inline", "filename": "banner.png", "type": "image/png"}], "batch_id": "sendgrid_batch_id", "categories": ["May", "2016"], "content": [{"type": "text/plain", "value": "some text here"}, {"type": "text/html", "value": "<html><body>some text here</body></html>"}], "custom_args": {"campaign": "welcome", "weekday": "morning"}, "from": {"email": "test@example.com", "name": "Example User"}, "headers": {"X-Test1": "test1", "X-Test3": "test2", "X-Test4": "test4"}, "ip_pool_name": "24", "mail_settings": {"bcc": {"email": "test@example.com", "enable": true}, "bypass_list_management": {"enable": true}, "footer": {"enable": true, "html": "<html><body>Footer Text</body></html>", "text": "Footer Text"}, "sandbox_mode": {"enable": true}, "spam_check": {"enable": true, "post_to_url": "https://spamcatcher.sendgrid.com", "threshold": 1}}, "personalizations": [{"bcc": [{"email": "test@example.com"}, {"email": "test@example.com"}], "cc": [{"email": "test@example.com", "name": "Example User"}, {"email": "test@example.com", "name": "Example User"}], "custom_args": {"type": "marketing", "user_id": "343"}, "headers": {"X-Mock": "true", "X-Test": "test"}, "send_at": 1443636843, "subject": "Hello World from the Personalized SendGrid Python Library", "substitutions": {"%city%": "Denver", "%name%": "Example User"}, "to": [{"email": "test@example.com", "name": "Example User"}, {"email": "test@example.com", "name": "Example User"}]}, {"bcc": [{"email": "test@example.com"}, {"email": "test@example.com"}], "cc": [{"email": "test@example.com", "name": "Example User"}, {"email": "test@example.com", "name": "Example User"}], "custom_args": {"type": "marketing", "user_id": "343"}, "headers": {"X-Mock": "true", "X-Test": "test"}, "send_at": 1443636843, "subject": "Hello World from the Personalized SendGrid Python Library", "substitutions": {"%city%": "Denver", "%name%": "Example User"}, "to": [{"email": "test@example.com", "name": "Example User"}, {"email": "test@example.com", "name": "Example User"}]}], "reply_to": {"email": "test@example.com"}, "sections": {"%section1%": "Substitution Text for Section 1", "%section2%": "Substitution Text for Section 2"}, "send_at": 1443636842, "subject": "Hello World from the SendGrid Python Library", "template_id": "13b8f94f-bcae-4ec6-b752-70d6cb59f932", "tracking_settings": {"click_tracking": {"enable": true, "enable_text": true}, "ganalytics": {"enable": true, "utm_campaign": "some campaign", "utm_content": "some content", "utm_medium": "some medium", "utm_source": "some source", "utm_term": "some term"}, "open_tracking": {"enable": true, "substitution_tag": "Optional tag to replace with the open image in the body of the message"}, "subscription_tracking": {"enable": true, "html": "<html><body>html to insert into the text/html portion of the message</body></html>", "substitution_tag": "Optional tag to replace with the open image in the body of the message", "text": "text to insert into the text/plain portion of the message"}}}' )
0 commit comments