|
32 | 32 |
|
33 | 33 |
|
34 | 34 | class UnitTests(unittest.TestCase): |
| 35 | + |
35 | 36 | def test_helloEmail(self): |
36 | 37 | self.maxDiff = None |
37 | 38 |
|
@@ -207,6 +208,211 @@ def test_kitchenSink(self): |
207 | 208 |
|
208 | 209 | mail.set_reply_to(Email("test@example.com")) |
209 | 210 |
|
| 211 | + expected_result = { |
| 212 | + "asm": { |
| 213 | + "group_id": 99, |
| 214 | + "groups_to_display": [4, 5, 6, 7, 8] |
| 215 | + }, |
| 216 | + "attachments": [ |
| 217 | + { |
| 218 | + "content": "TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3" |
| 219 | + "RldHVyIGFkaXBpc2NpbmcgZWxpdC4gQ3JhcyBwdW12", |
| 220 | + "content_id": "Balance Sheet", |
| 221 | + "disposition": "attachment", |
| 222 | + "filename": "balance_001.pdf", |
| 223 | + "type": "application/pdf" |
| 224 | + }, |
| 225 | + { |
| 226 | + "content": "BwdW", |
| 227 | + "content_id": "Banner", |
| 228 | + "disposition": "inline", |
| 229 | + "filename": "banner.png", |
| 230 | + "type": "image/png" |
| 231 | + } |
| 232 | + ], |
| 233 | + "batch_id": "sendgrid_batch_id", |
| 234 | + "categories": [ |
| 235 | + "May", |
| 236 | + "2016" |
| 237 | + ], |
| 238 | + "content": [ |
| 239 | + { |
| 240 | + "type": "text/plain", |
| 241 | + "value": "some text here" |
| 242 | + }, |
| 243 | + { |
| 244 | + "type": "text/html", |
| 245 | + "value": "<html><body>some text here</body></html>" |
| 246 | + } |
| 247 | + ], |
| 248 | + "custom_args": { |
| 249 | + "campaign": "welcome", |
| 250 | + "weekday": "morning" |
| 251 | + }, |
| 252 | + "from": { |
| 253 | + "email": "test@example.com", |
| 254 | + "name": "Example User" |
| 255 | + }, |
| 256 | + "headers": { |
| 257 | + "X-Test1": "test1", |
| 258 | + "X-Test3": "test2", |
| 259 | + "X-Test4": "test4" |
| 260 | + }, |
| 261 | + "ip_pool_name": "24", |
| 262 | + "mail_settings": { |
| 263 | + "bcc": { |
| 264 | + "email": "test@example.com", |
| 265 | + "enable": True |
| 266 | + }, |
| 267 | + "bypass_list_management": { |
| 268 | + "enable": True |
| 269 | + }, |
| 270 | + "footer": { |
| 271 | + "enable": True, |
| 272 | + "html": "<html><body>Footer Text</body></html>", |
| 273 | + "text": "Footer Text" |
| 274 | + }, |
| 275 | + "sandbox_mode": { |
| 276 | + "enable": True |
| 277 | + }, |
| 278 | + "spam_check": { |
| 279 | + "enable": True, |
| 280 | + "post_to_url": "https://spamcatcher.sendgrid.com", |
| 281 | + "threshold": 1 |
| 282 | + } |
| 283 | + }, |
| 284 | + "personalizations": [ |
| 285 | + { |
| 286 | + "bcc": [ |
| 287 | + { |
| 288 | + "email": "test@example.com" |
| 289 | + }, |
| 290 | + { |
| 291 | + "email": "test@example.com" |
| 292 | + } |
| 293 | + ], |
| 294 | + "cc": [ |
| 295 | + { |
| 296 | + "email": "test@example.com", |
| 297 | + "name": "Example User" |
| 298 | + }, |
| 299 | + { |
| 300 | + "email": "test@example.com", |
| 301 | + "name": "Example User" |
| 302 | + } |
| 303 | + ], |
| 304 | + "custom_args": { |
| 305 | + "type": "marketing", |
| 306 | + "user_id": "343" |
| 307 | + }, |
| 308 | + "headers": { |
| 309 | + "X-Mock": "true", |
| 310 | + "X-Test": "test" |
| 311 | + }, |
| 312 | + "send_at": 1443636843, |
| 313 | + "subject": "Hello World from the Personalized SendGrid " |
| 314 | + "Python Library", |
| 315 | + "substitutions": { |
| 316 | + "%city%": "Denver", |
| 317 | + "%name%": "Example User" |
| 318 | + }, |
| 319 | + "to": [ |
| 320 | + { |
| 321 | + "email": "test@example.com", |
| 322 | + "name": "Example User" |
| 323 | + }, |
| 324 | + { |
| 325 | + "email": "test@example.com", |
| 326 | + "name": "Example User" |
| 327 | + } |
| 328 | + ] |
| 329 | + }, |
| 330 | + { |
| 331 | + "bcc": [ |
| 332 | + { |
| 333 | + "email": "test@example.com" |
| 334 | + }, |
| 335 | + { |
| 336 | + "email": "test@example.com" |
| 337 | + } |
| 338 | + ], |
| 339 | + "cc": [ |
| 340 | + { |
| 341 | + "email": "test@example.com", |
| 342 | + "name": "Example User" |
| 343 | + }, |
| 344 | + { |
| 345 | + "email": "test@example.com", |
| 346 | + "name": "Example User" |
| 347 | + } |
| 348 | + ], |
| 349 | + "custom_args": { |
| 350 | + "type": "marketing", |
| 351 | + "user_id": "343" |
| 352 | + }, |
| 353 | + "headers": { |
| 354 | + "X-Mock": "true", |
| 355 | + "X-Test": "test" |
| 356 | + }, |
| 357 | + "send_at": 1443636843, |
| 358 | + "subject": "Hello World from the Personalized SendGrid " |
| 359 | + "Python Library", |
| 360 | + "substitutions": { |
| 361 | + "%city%": "Denver", |
| 362 | + "%name%": "Example User" |
| 363 | + }, |
| 364 | + "to": [ |
| 365 | + { |
| 366 | + "email": "test@example.com", |
| 367 | + "name": "Example User" |
| 368 | + }, |
| 369 | + { |
| 370 | + "email": "test@example.com", |
| 371 | + "name": "Example User" |
| 372 | + } |
| 373 | + ] |
| 374 | + } |
| 375 | + ], |
| 376 | + "reply_to": { |
| 377 | + "email": "test@example.com" |
| 378 | + }, |
| 379 | + "sections": { |
| 380 | + "%section1%": "Substitution Text for Section 1", |
| 381 | + "%section2%": "Substitution Text for Section 2" |
| 382 | + }, |
| 383 | + "send_at": 1443636842, |
| 384 | + "subject": "Hello World from the SendGrid Python Library", |
| 385 | + "template_id": "13b8f94f-bcae-4ec6-b752-70d6cb59f932", |
| 386 | + "tracking_settings": { |
| 387 | + "click_tracking": { |
| 388 | + "enable": True, |
| 389 | + "enable_text": True |
| 390 | + }, |
| 391 | + "ganalytics": { |
| 392 | + "enable": True, |
| 393 | + "utm_campaign": "some campaign", |
| 394 | + "utm_content": "some content", |
| 395 | + "utm_medium": "some medium", |
| 396 | + "utm_source": "some source", |
| 397 | + "utm_term": "some term" |
| 398 | + }, |
| 399 | + "open_tracking": { |
| 400 | + "enable": True, |
| 401 | + "substitution_tag": "Optional tag to replace with the " |
| 402 | + "open image in the body of the message" |
| 403 | + }, |
| 404 | + "subscription_tracking": { |
| 405 | + "enable": True, |
| 406 | + "html": "<html><body>html to insert into the text/html " |
| 407 | + "portion of the message</body></html>", |
| 408 | + "substitution_tag": "Optional tag to replace with the open" |
| 409 | + " image in the body of the message", |
| 410 | + "text": "text to insert into the text/plain portion of" |
| 411 | + " the message" |
| 412 | + } |
| 413 | + } |
| 414 | + } |
210 | 415 | self.assertEqual( |
211 | 416 | json.dumps(mail.get(), sort_keys=True), |
212 | | - '{"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"}}}') |
| 417 | + json.dumps(expected_result, sort_keys=True) |
| 418 | + ) |
0 commit comments