|
10 | 10 | EmailMessage = message.Message
|
11 | 11 |
|
12 | 12 | from sendgrid.helpers.mail import (
|
13 |
| - Asm, |
14 |
| - ApiKeyIncludedException, |
15 |
| - Attachment, |
16 |
| - BccSettings, |
17 |
| - BypassListManagement, |
18 |
| - Category, |
19 |
| - ClickTracking, |
20 |
| - Content, |
21 |
| - CustomArg, |
22 |
| - DynamicTemplateData, |
23 |
| - Email, |
24 |
| - FooterSettings, |
25 |
| - From, |
26 |
| - Ganalytics, |
27 |
| - Header, |
28 |
| - Mail, |
29 |
| - MailSettings, |
30 |
| - OpenTracking, |
31 |
| - Personalization, |
32 |
| - SandBoxMode, |
33 |
| - Section, |
34 |
| - SendGridException, |
35 |
| - SpamCheck, |
36 |
| - Subject, |
37 |
| - SubscriptionTracking, |
38 |
| - Substitution, |
39 |
| - TrackingSettings, |
40 |
| - To, |
41 |
| - ValidateApiKey |
| 13 | + Asm, ApiKeyIncludedException, Attachment, BccSettings, |
| 14 | + BypassListManagement, Category, ClickTracking, Content, CustomArg, |
| 15 | + DynamicTemplateData, Email, FooterSettings, From, Ganalytics, Header, |
| 16 | + Mail, MailSettings, OpenTracking, Personalization, SandBoxMode, Section, |
| 17 | + SendGridException, SpamCheck, Subject, SubscriptionTracking, Substitution, |
| 18 | + TrackingSettings, To, ValidateApiKey |
42 | 19 | )
|
43 | 20 |
|
44 | 21 |
|
45 | 22 | class UnitTests(unittest.TestCase):
|
46 | 23 |
|
| 24 | + def test_asm(self): |
| 25 | + from sendgrid.helpers.mail import (GroupId, GroupsToDisplay) |
| 26 | + asm1 = Asm(GroupId(1), GroupsToDisplay([1, 2, 3])) |
| 27 | + asm2 = Asm(1, [1, 2, 3]) |
| 28 | + self.assertEqual( |
| 29 | + asm1.group_id.get(), asm2.group_id.get()) |
| 30 | + self.assertEqual( |
| 31 | + asm1.groups_to_display.get(), asm2.groups_to_display.get()) |
| 32 | + |
| 33 | + def test_attachment(self): |
| 34 | + from sendgrid.helpers.mail import (FileContent, FileType, FileName, |
| 35 | + Disposition, ContentId) |
| 36 | + a1 = Attachment( |
| 37 | + FileContent('Base64EncodedString'), |
| 38 | + FileName('example.pdf'), |
| 39 | + FileType('application/pdf'), |
| 40 | + Disposition('attachment'), |
| 41 | + ContentId('123') |
| 42 | + ) |
| 43 | + a2 = Attachment( |
| 44 | + 'Base64EncodedString', |
| 45 | + 'example.pdf', |
| 46 | + 'application/pdf', |
| 47 | + 'attachment', |
| 48 | + '123' |
| 49 | + ) |
| 50 | + self.assertEqual(a1.file_content.get(), a2.file_content.get()) |
| 51 | + self.assertEqual(a1.file_name.get(), a2.file_name.get()) |
| 52 | + self.assertEqual(a1.file_type.get(), a2.file_type.get()) |
| 53 | + self.assertEqual(a1.disposition.get(), a2.disposition.get()) |
| 54 | + self.assertEqual(a1.content_id.get(), a2.content_id.get()) |
| 55 | + |
| 56 | + def test_batch_id(self): |
| 57 | + from sendgrid.helpers.mail import BatchId |
| 58 | + |
| 59 | + b1 = BatchId('1') |
| 60 | + self.assertEqual('1', b1.get()) |
| 61 | + |
47 | 62 | # Send a Single Email to a Single Recipient
|
48 | 63 | def test_single_email_to_a_single_recipient(self):
|
49 | 64 | from sendgrid.helpers.mail import (Mail, From, To, Subject,
|
|
0 commit comments