
    M}bg                       d dl Z d dlZ	 d dlmZ n# e$ r d dlmZ ej        ZY nw xY wd dlm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZmZmZmZ dZ e j        dddd	edd
ddgdddddddgigdd          Z G d dej                  ZdS )    N)EmailMessage)message)Asm
AttachmentClickTrackingContentDynamicTemplateDataEmailFromMailPersonalizationSubjectSubstitutionToCcBccTrackingSettingsa  <!doctype html><html amp4email><head><meta charset="utf-8"><script async src="https://cdn.ampproject.org/v0.js"></script><style amp4email-boilerplate>body{visibility:hidden}</style><script async custom-element="amp-carousel" src="https://cdn.ampproject.org/v0/amp-carousel-0.1.js"></script><style amp-custom>.emailbody {padding: 16px;}.helloworld {font-family: Helvetica;color: red;font-size: 24px;padding-bottom: 8px;}.images {max-width: 100%;}</style></head><body><div class="emailbody"><h1 class="helloworld">Hello!</h1><amp-img src="https://amp.dev/static/samples/img/amp.jpg" width="800" height="600" layout="responsive"></amp-img></div></body></html>
text/plain)and easy to do anywhere, even with Pythontypevaluetext/x-amp-html	text/html:<strong>and easy to do anywhere, even with Python</strong>test+from@example.comExample From Nameemailnametotest+to@example.comExample To NameSending with SendGrid is Funcontentfrompersonalizationssubjectc                   ^   e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z d Z!d  Z"d! Z#d" Z$d# Z%d$ Z&d% Z'd& Z(d' Z)d( Z*d) Z+d* Z,d+ Z-d, Z.d- Z/d. Z0d/ Z1d0 Z2d1 Z3d2 Z4d3 Z5d4 Z6d5 Z7d6 Z8d7 Z9d8 Z:d9S ):	UnitTestsc                    ddl m}m} t           |d           |g d                    }t          dg d          }|                     |j                                        |j                                                   |                     |j                                        |j                                                   d S )Nr   )GroupIdGroupsToDisplay   )r/         )sendgrid.helpers.mailr-   r.   r   assertEqualgroup_idgetgroups_to_display)selfr-   r.   asm1asm2s        n/home/e360mart.nyusoft.in/public_html/e360mart_env/lib/python3.11/site-packages/test/unit/test_mail_helpers.pytest_asmzUnitTests.test_asm9   s    DDDDDDDD771::yyy99::1iii  M!2!2!4!4	6 	6 	6"&&(($*@*D*D*F*F	H 	H 	H 	H 	H    c           	      p   ddl m}m}m}m}m} t           |d           |d           |d           |d           |d                    }t          ddddd          }|                     |j        	                                |j        	                                           |                     |j
        	                                |j
        	                                           |                     |j        	                                |j        	                                           |                     |j        	                                |j        	                                           |                     |j        	                                |j        	                                           d S )Nr   )FileContentFileTypeFileNameDisposition	ContentIdBase64EncodedStringzexample.pdfapplication/pdf
attachment123)r2   r>   r?   r@   rA   rB   r   r3   file_contentr5   	file_name	file_typedisposition
content_id)r7   r>   r?   r@   rA   rB   a1a2s           r:   test_attachmentzUnitTests.test_attachmentB   s   	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	CK-..H]##H&''K%%Ie
 
 !
 
 	,,..0C0C0E0EFFF))++R\-=-=-?-?@@@))++R\-=-=-?-?@@@++--r~/A/A/C/CDDD**,,bm.?.?.A.ABBBBBr<   c                 x    ddl m}  |d          }|                     d|                                           d S )Nr   )BatchId1)r2   rP   r3   r5   )r7   rP   b1s      r:   test_batch_idzUnitTests.test_batch_idY   sE    111111WS\\bffhh'''''r<   c           	         ddl m}m}m}m}m}m} d | _         | |dd           |dd           |d           |d           |d	          
          }|                      |j	                    t          j        d                     d S )Nr   r   r   r   r   PlainTextContentHtmlContentr   r   r"   r#   r$   r   r   
from_email	to_emailsr)   plain_text_contenthtml_content  {
                "content": [
                    {
                        "type": "text/plain",
                        "value": "and easy to do anywhere, even with Python"
                    },
                    {
                        "type": "text/html",
                        "value": "<strong>and easy to do anywhere, even with Python</strong>"
                    }
                ],
                "from": {
                    "email": "test+from@example.com",
                    "name": "Example From Name"
                },
                "personalizations": [
                    {
                        "to": [
                            {
                                "email": "test+to@example.com",
                                "name": "Example To Name"
                            }
                        ]
                    }
                ],
                "subject": "Sending with SendGrid is Fun"
            }r2   r   r   r   r   rV   rW   maxDiffr3   r5   jsonloadsr7   r   r   r   r   rV   rW   r   s           r:   'test_single_email_to_a_single_recipientz1UnitTests.test_single_email_to_a_single_recipient`   s   	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J$t35HIIb.0ABBG:;;//; =  =$LN NO O O 	GKMMJ   	
 	
 	
 	
 	
r<   c                 V   ddl m}m}m}m}m}m} d| _         |            } |dd          |_         |dd          |_	         |d          |_
         |d	          |_         |d
          |_        |                      |j                    t          j        d                     dS )zKTests bug found in Issue-451 with Content ordering causing a crash
        r   rU   Nr   r   r"   r#   r$   r   r   r]   )r2   r   r   r   r   rV   rW   r_   rY   r!   r)   r&   r3   r5   r`   ra   rb   s           r:   8test_single_email_to_a_single_recipient_content_reversedzBUnitTests.test_single_email_to_a_single_recipient_content_reversed   s#   	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J$&&!T"9;NOOR-/@AA
!'"@AA%+HJ J**79 9 	GKMMJ   	
 	
 	
 	
 	
r<   c           	      8   ddl m}m}m}m}m}m} d | _         |dd           |dd          g} | |dd          | |d	           |d
           |d                    }|                      |j	                    t          j        d                     d S )Nr   rU   test+to0@example.comExample To Name 0test+to1@example.comExample To Name 1r   r   r$   r   r   rX   a}  {
                "content": [
                    {
                        "type": "text/plain",
                        "value": "and easy to do anywhere, even with Python"
                    },
                    {
                        "type": "text/html",
                        "value": "<strong>and easy to do anywhere, even with Python</strong>"
                    }
                ],
                "from": {
                    "email": "test+from@example.com",
                    "name": "Example From Name"
                },
                "personalizations": [
                    {
                        "to": [
                            {
                                "email": "test+to0@example.com",
                                "name": "Example To Name 0"
                            },
                            {
                                "email": "test+to1@example.com",
                                "name": "Example To Name 1"
                            }
                        ]
                    }
                ],
                "subject": "Sending with SendGrid is Fun"
            }r^   )	r7   r   r   r   r   rV   rW   rZ   r   s	            r:   /test_send_a_single_email_to_multiple_recipientsz9UnitTests.test_send_a_single_email_to_multiple_recipients   s9   	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	JB%':;;B%':;;
	 $t35HIIG:;;//; =  =$LN NO O O 	GKMMJ   !	
 !	
 !	
 !	
 !	
r<   c           	      Z   ddl m}m}m}m}m}m}m} d | _         | |dd           |dd           |d           |d           |d	          
          } |d           |d          g|_	        | 
                     |j                    t          j        d                     d S )Nr   )r   r   ReplyTor   r   rV   rW   r   r   rg   r#   r$   r   r   rX   ztest+reply_to_1@example.com)r   ztest+reply_to_2@example.coma  {
                "content": [
                    {
                        "type": "text/plain",
                        "value": "and easy to do anywhere, even with Python"
                    },
                    {
                        "type": "text/html",
                        "value": "<strong>and easy to do anywhere, even with Python</strong>"
                    }
                ],
                "from": {
                    "email": "test+from@example.com",
                    "name": "Example From Name"
                },
                "personalizations": [
                    {
                        "to": [
                            {
                                "email": "test+to0@example.com",
                                "name": "Example To Name"
                            }
                        ]
                    }
                ],
                "reply_to_list": [
                    {
                        "email": "test+reply_to_1@example.com"
                    },
                    {
                        "email": "test+reply_to_2@example.com"
                    }
                ],
                "subject": "Sending with SendGrid is Fun"
            })r2   r   r   rm   r   r   rV   rW   r_   reply_to_listr3   r5   r`   ra   )	r7   r   r   rm   r   r   rV   rW   r   s	            r:   9test_send_a_single_email_with_multiple_reply_to_addresseszCUnitTests.test_send_a_single_email_with_multiple_reply_to_addresses   sL   	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J$t35HIIb/1BCCG:;;//0[\\$%abbd d d ")1N!O!O!OQXQXa~QQQ  !AGKMMJ " " "%	
 %	
 %	
 %	
 %	
r<   c           
         ddl m}m}m}m}m}m}m} d | _         |dd |dd           |dd          g |d	          
           |dd |dd           |dd          g          g} |dd          }	 | |dd          | |d           |d           |d          |	d          }
| 	                     |
j
                    t          j        d                     d S )Nr   )r   r   r   r   rV   rW   r   rg   zExample Name 0z-name-zExample Name Substitution 0z-github-zhttps://example.com/test0zOverride Global Subject)r   r    substitutionsr)   ri   Example Name 1zExample Name Substitution 1zhttps://example.com/test1)r   r    rq   z-time-z2019-01-01 00:00:00r   r   z	Hi -name-z8Hello -name-, your URL is -github-, email sent at -time-z[<strong>Hello -name-, your URL is <a href="-github-">here</a></strong> email sent at -time-T)rY   rZ   r)   r[   r\   global_substitutionsis_multipleaR  {
                "content": [
                    {
                        "type": "text/plain",
                        "value": "Hello -name-, your URL is -github-, email sent at -time-"
                    },
                    {
                        "type": "text/html",
                        "value": "<strong>Hello -name-, your URL is <a href=\"-github-\">here</a></strong> email sent at -time-"
                    }
                ],
                "from": {
                    "email": "test+from@example.com",
                    "name": "Example From Name"
                },
                "personalizations": [
                    {
                        "substitutions": {
                            "-github-": "https://example.com/test1",
                            "-name-": "Example Name Substitution 1",
                            "-time-": "2019-01-01 00:00:00"
                        },
                        "to": [
                            {
                                "email": "test+to1@example.com",
                                "name": "Example Name 1"
                            }
                        ]
                    },
                    {
                        "subject": "Override Global Subject",
                        "substitutions": {
                            "-github-": "https://example.com/test0",
                            "-name-": "Example Name Substitution 0",
                            "-time-": "2019-01-01 00:00:00"
                        },
                        "to": [
                            {
                                "email": "test+to0@example.com",
                                "name": "Example Name 0"
                            }
                        ]
                    }
                ],
                "subject": "Hi -name-"
            })r2   r   r   r   r   rV   rW   r   r_   r3   r5   r`   ra   )r7   r   r   r   r   rV   rW   r   rZ   rs   r   s              r:   +test_multiple_emails_to_multiple_recipientsz5UnitTests.test_multiple_emails_to_multiple_recipients"  s   	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9  B+$<*GHH<
,GHH w899; ; ; B+$<*GHH<
,GHH  
	  ,|H6KLL$t35HIIGK((//J L  L$oq q!5	 	 	 	GKMMJ - - -0	
 0	
 0	
 0	
 0	
r<   c           
      H   ddl m}m}m}m}m}m}m} d | _         | |dd           |dd           |d           |d           |t                     |d	          
          }| 
                     |j                    t          j        t                               d S )Nr   r   r   r   r   rV   rW   AmpHtmlContentr   r   r"   r#   r$   r   r   )rY   rZ   r)   r[   amp_html_contentr\   )r2   r   r   r   r   rV   rW   rx   r_   ry   r3   r5   r`   ra   -response_content_with_all_three_mime_contents	r7   r   r   r   r   rV   rW   rx   r   s	            r:   Ctest_single_email_with_all_three_email_contents_to_single_recipientzMUnitTests.test_single_email_with_all_three_email_contents_to_single_recipientu  s-   	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z$t35HIIb.0ABBG:;;//; =  =+^,<==$LN N	
 	
 	
 	GKMMJDEE	
 	
 	
 	
 	
r<   c           	         ddl m}m}m}m}m}m}m} d | _         | |dd           |dd           |d           |t                     |d          	          }t          j        d
t          ddddgdddddddgigdd          }	|                      |j                    t          j        |	                     d S )Nr   rw   r   r   r"   r#   r$   r   )rY   rZ   r)   ry   r\   r   r   r   r   r!   r%   r2   r   r   r   r   rV   rW   rx   r_   ry   r`   dumpsr3   r5   ra   
r7   r   r   r   r   rV   rW   rx   r   response_contents
             r:   @test_single_email_with_amp_and_html_contents_to_single_recipientzJUnitTests.test_single_email_with_amp_and_html_contents_to_single_recipient  s   	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z$t35HIIb.0ABBG:;;+^,<==$LN N
 
 
  : .- 
 (Y 	 1+  %:$5 	! 63'
 '
  6 	GKMMJ'((	
 	
 	
 	
 	
r<   c           	         ddl m}m}m}m}m}m}m} d | _         | |dd           |dd           |d           |d           |t                    	          }t          j        d
dddt          dgdddddddgigdd          }	|                      |j                    t          j        |	                     d S )Nr   rw   r   r   r"   r#   r$   r   )rY   rZ   r)   r[   ry   r   r   r   r   r!   r%   r~   r   s
             r:   Atest_single_email_with_amp_and_plain_contents_to_single_recipientzKUnitTests.test_single_email_with_amp_and_plain_contents_to_single_recipient  s   	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z$t35HIIb.0ABBG:;;//; =  =+^,<==
 
 
  : )H 
 .- 	 1+  %:$5 	! 63'
 '
  6 	GKMMJ'((	
 	
 	
 	
 	
r<   c                 l   ddl m}m}m}m}m}m}m} d | _         | |dd           |dd           |d                    } |d	          |_	         |t                    |_	         |d
          |_	        |                      |j                    t          j        t                               d S Nr   rw   r   r   r"   r#   r$   rY   rZ   r)   r   r   r2   r   r   r   r   rV   rW   rx   r_   r&   ry   r3   r5   r`   ra   rz   r{   s	            r:   gtest_single_email_with_all_three_contents_in_collapsed_order_of_plain_amp_html_content_single_recipientzqUnitTests.test_single_email_with_all_three_contents_in_collapsed_order_of_plain_amp_html_content_single_recipient  s;   	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z$t35HIIb.0ABBG:;;
 
 

 +*79 9(.)9::%+HJ J 	GKMMJDEE	
 	
 	
 	
 	
r<   c                 l   ddl m}m}m}m}m}m}m} d | _         | |dd           |dd           |d                    } |d	          |_	         |d
          |_	         |t                    |_	        |                      |j                    t          j        t                               d S r   r   r{   s	            r:   gtest_single_email_with_all_three_contents_in_collapsed_order_of_plain_html_amp_content_single_recipientzqUnitTests.test_single_email_with_all_three_contents_in_collapsed_order_of_plain_html_amp_content_single_recipient  s9   	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z$t35HIIb.0ABBG:;;
 
 

 +*79 9%+HJ J(.)9::GKMMJDEE	
 	
 	
 	
 	
r<   c                 l   ddl m}m}m}m}m}m}m} d | _         | |dd           |dd           |d                    } |d	          |_	         |d
          |_	         |t                    |_	        |                      |j                    t          j        t                               d S Nr   rw   r   r   r"   r#   r$   r   r   r   r   r{   s	            r:   gtest_single_email_with_all_three_contents_in_collapsed_order_of_html_plain_amp_content_single_recipientzqUnitTests.test_single_email_with_all_three_contents_in_collapsed_order_of_html_plain_amp_content_single_recipient  s9   	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z$t35HIIb.0ABBG:;;
 
 

 &+HJ J**79 9(.)9::GKMMJDEE	
 	
 	
 	
 	
r<   c                 l   ddl m}m}m}m}m}m}m} d | _         | |dd           |dd           |d                    } |d	          |_	         |t                    |_	         |d
          |_	        |                      |j                    t          j        t                               d S r   r   r{   s	            r:   gtest_single_email_with_all_three_contents_in_collapsed_order_of_html_amp_plain_content_single_recipientzqUnitTests.test_single_email_with_all_three_contents_in_collapsed_order_of_html_amp_plain_content_single_recipient   s;   	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z$t35HIIb.0ABBG:;;
 
 

 &+HJ J(.)9::**79 9 	GKMMJDEE	
 	
 	
 	
 	
r<   c                 l   ddl m}m}m}m}m}m}m} d | _         | |dd           |dd           |d                    } |t                    |_
         |d	          |_
         |d
          |_
        |                      |j                    t          j        t                               d S r   r2   r   r   r   r   rV   rW   rx   r_   ry   r&   r3   r5   r`   ra   rz   r{   s	            r:   gtest_single_email_with_all_three_contents_in_collapsed_order_of_amp_html_plain_content_single_recipientzqUnitTests.test_single_email_with_all_three_contents_in_collapsed_order_of_amp_html_plain_content_single_recipient4  s;   	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z$t35HIIb.0ABBG:;;
 
 

 ).)9::%+HJ J**79 9 	GKMMJDEE	
 	
 	
 	
 	
r<   c                 l   ddl m}m}m}m}m}m}m} d | _         | |dd           |dd           |d                    } |t                    |_
         |d	          |_
         |d
          |_
        |                      |j                    t          j        t                               d S r   r   r{   s	            r:   gtest_single_email_with_all_three_contents_in_collapsed_order_of_amp_plain_html_content_single_recipientzqUnitTests.test_single_email_with_all_three_contents_in_collapsed_order_of_amp_plain_html_content_single_recipientH  s;   	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z 	Z$t35HIIb.0ABBG:;;
 
 

 ).)9::**79 9%+HJ J 	GKMMJDEE	
 	
 	
 	
 	
r<   c           
         ddl m}m} d | _        ddgddgg}|                     t
                    5  t          t          dd          |t          d	           |d
           |d                     d d d            d S # 1 swxY w Y   d S )Nr   rV   rW   rg   rh   ri   rj   r   r   r$   r   r   rX   )	r2   rV   rW   r_   assertRaises
ValueErrorr   r   r   r7   rV   rW   rZ   s       r:   <test_value_error_is_raised_on_to_emails_set_to_list_of_listszFUnitTests.test_value_error_is_raised_on_to_emails_set_to_list_of_lists^  s*   IIIIIIII#%89#%89
	
 z** 	S 	S 79LMM# >??#3#3?$A $A([PR RS S S S	S 	S 	S 	S 	S 	S 	S 	S 	S 	S 	S 	S 	S 	S 	S 	S 	S 	Ss   ABBBc           	      &   ddl m}m} d | _        ddg}t	          t          dd          |t          d           |d           |d	          
          }|                     t                    5  ddg|_	        d d d            d S # 1 swxY w Y   d S )Nr   r   rg   rh   ri   rj   r   r   r$   r   r   rX   ztest+reply_to0@example.comztest+reply_to1@example.com
r2   rV   rW   r_   r   r   r   r   r   rn   r7   rV   rW   rZ   mails        r:   Dtest_value_error_is_raised_on_to_emails_set_to_reply_to_list_of_strszNUnitTests.test_value_error_is_raised_on_to_emails_set_to_reply_to_list_of_strsp  s(   IIIIIIII99
	
 35HII:;;//; =  =$LN NO O O z** 	^ 	^">@\!]D	^ 	^ 	^ 	^ 	^ 	^ 	^ 	^ 	^ 	^ 	^ 	^ 	^ 	^ 	^ 	^ 	^ 	^s   /
BB
B
c           	      $   ddl m}m} d | _        ddg}t	          t          dd          |t          d           |d           |d	          
          }|                     t                    5  dg|_	        d d d            d S # 1 swxY w Y   d S )Nr   r   r   r   r   r   r$   r   r   rX   )ztest+reply_to@example.comz	Test Namer   r   s        r:   Ftest_value_error_is_raised_on_to_emails_set_to_reply_to_list_of_tupleszPUnitTests.test_value_error_is_raised_on_to_emails_set_to_reply_to_list_of_tuples  s%   IIIIIIII99
	
 35HII:;;//; =  =$LN NO O O z** 	N 	N"L!MD	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	Ns   /	BB	B	c           	          ddl m}m} d | _        ddg}t	          t          dd          |t          d           |d           |d	          
           d S )Nr   r   r   r   r   r   r$   r   r   rX   r2   rV   rW   r_   r   r   r   r   s       r:   ;test_error_is_not_raised_on_to_emails_set_to_list_of_tupleszEUnitTests.test_error_is_not_raised_on_to_emails_set_to_list_of_tuples  s    IIIIIIII99
	
 	35HII:;;//; =  =$LN N	O 	O 	O 	O 	O 	Or<   c           	          ddl m}m} d | _        ddg}t	          t          dd          |t          d           |d           |d	          
           d S )Nr   r   rg   ri   r   r   r$   r   r   rX   r   r   s       r:   9test_error_is_not_raised_on_to_emails_set_to_list_of_strszCUnitTests.test_error_is_not_raised_on_to_emails_set_to_list_of_strs  s    IIIIIIII+-CD	35HII:;;//; =  =$LN N	O 	O 	O 	O 	O 	Or<   c           	          ddl m}m} d | _        d}t	          t          dd          |t          d           |d           |d          	           d S )
Nr   r   rg   r   r   r$   r   r   rX   r   r   s       r:   2test_error_is_not_raised_on_to_emails_set_to_a_strz<UnitTests.test_error_is_not_raised_on_to_emails_set_to_a_str  s    IIIIIIII*	35HII:;;//; =  =$LN N	O 	O 	O 	O 	O 	Or<   c           	          ddl m}m} d | _        d}t	          t          dd          |t          d           |d           |d          	           d S )
Nr   r   r   r   r   r$   r   r   rX   r   r   s       r:   4test_error_is_not_raised_on_to_emails_set_to_a_tuplez>UnitTests.test_error_is_not_raised_on_to_emails_set_to_a_tuple  s    IIIIIIIIA	35HII:;;//; =  =$LN N	O 	O 	O 	O 	O 	Or<   c           	         ddl m}m} d | _        t	          dd          t          dd          t          dd          g}t          t          d	d
          |t          d           |d           |d                     d S )Nr   r   rg   rh   ztest+bcc@example.comzExample Bcc Name 1ztest+cc@example.comzExample Cc Name 2r   r   r$   r   r   rX   )
r2   rV   rW   r_   r   r   r   r   r   r   r   s       r:   5test_error_is_not_raised_on_to_emails_includes_bcc_ccz?UnitTests.test_error_is_not_raised_on_to_emails_includes_bcc_cc  s    IIIIIIII%':;;&(<==$&9::
	 	35HII:;;//; =  =$LN N	O 	O 	O 	O 	O 	Or<   c                     d | _         t                      }t          dd          }|                    |           |                    |           |                     |                                g|j                   d S Nrg   rh   r_   r   r   	add_emailr3   r5   tos)r7   pto_emails      r:   >test_personalization_add_email_filters_out_duplicate_to_emailszHUnitTests.test_personalization_add_email_filters_out_duplicate_to_emails  r    ,.ABB	H	H(,,..)1511111r<   c                     d | _         t                      }t          dd          }t          dd          }|                    |           |                    |           |                     |                                g|j                   d S Nrg   rh   test+TO0@example.comr   )r7   r   r   to_email_with_capss       r:   Ltest_personalization_add_email_filters_out_duplicate_to_emails_ignoring_casezVUnitTests.test_personalization_add_email_filters_out_duplicate_to_emails_ignoring_case      ,.ABB 68KLL	H	&'''(,,..)1511111r<   c                     d | _         t                      }t          dd          }|                    |           |                     |                                |j                   d S )Nr   zExample From)r_   r   r   set_fromr3   r5   rY   )r7   r   rY   s      r:   #test_personalization_set_from_emailz-UnitTests.test_personalization_set_from_email  s^    1>BB
	

:))1<88888r<   c                     d | _         t                      }t          dd          }|                    |           |                    |           |                     |                                g|j                   d S )Ntest+cc0@example.comExample Cc Name 0r_   r   r   r   r3   r5   ccs)r7   r   cc_emails      r:   4test_personalization_filters_out_duplicate_cc_emailsz>UnitTests.test_personalization_filters_out_duplicate_cc_emails  r   r<   c                     d | _         t                      }t          dd          }t          dd          }|                    |           |                    |           |                     |                                g|j                   d S Nr   r   test+CC0@example.comr   r7   r   r   cc_email_with_capss       r:   Btest_personalization_filters_out_duplicate_cc_emails_ignoring_casezLUnitTests.test_personalization_filters_out_duplicate_cc_emails_ignoring_case  r   r<   c                     d | _         t                      }t          dd          }|                    |           |                    |           |                     |                                g|j                   d S )Ntest+bcc0@example.comExample Bcc Name 0r_   r   r   r   r3   r5   bccs)r7   r   	bcc_emails      r:   5test_personalization_filters_out_duplicate_bcc_emailsz?UnitTests.test_personalization_filters_out_duplicate_bcc_emails  sr    /1EFF		I	I)--//*AF33333r<   c                     d | _         t                      }t          dd          }t          dd          }|                    |           |                    |           |                     |                                g|j                   d S Nr   r   test+BCC0@example.comr   r7   r   r   bcc_email_with_capss       r:   Ctest_personalization_filters_out_duplicate_bcc_emails_ignoring_casezMUnitTests.test_personalization_filters_out_duplicate_bcc_emails_ignoring_case   s    /1EFF	!"9;OPP	I	'((()--//*AF33333r<   c                     d | _         t                      }dddgdz  }||_        |                     |d         g|j                   d S )Nrg   rh   r   r0   r   r_   r   r   r3   r7   r   rZ   s      r:   Atest_personalization_tos_setter_filters_out_duplicate_dict_emailszKUnitTests.test_personalization_tos_setter_filters_out_duplicate_dict_emails+  V     6@SUUVYZZ	)A,/////r<   c                     d | _         t                      }ddd}ddd}||g}||_        |                     |g|j                   d S )Nrg   rh   r   r   r   r7   r   r   r   rZ   s        r:   Otest_personalization_tos_setter_filters_out_duplicate_dict_emails_ignoring_casezYUnitTests.test_personalization_tos_setter_filters_out_duplicate_dict_emails_ignoring_case4  c    4>QSS(>H[]]12	(QU+++++r<   c                     d | _         t                      }t          dd          gdz  }||_        |                     |d                                         g|j                   d S )Nrg   rh   r0   r   r_   r   r   r   r3   r5   r   s      r:   ?test_personalization_tos_setter_filters_out_duplicate_to_emailszIUnitTests.test_personalization_tos_setter_filters_out_duplicate_to_emails?  e    .0CDDEI	)A,**,,-qu55555r<   c                     d | _         t                      }t          dd          }t          dd          }||g}||_        |                     |                                g|j                   d S r   r   r   s        r:   Mtest_personalization_tos_setter_filters_out_duplicate_to_emails_ignoring_casezWUnitTests.test_personalization_tos_setter_filters_out_duplicate_to_emails_ignoring_caseI  sr    ,.ABB 68KLL12	(,,..)1511111r<   c                     d | _         t                      }dddgdz  }||_        |                     |d         g|j                   d S )Nr   r   r   r0   r   r_   r   r   r3   r7   r   	cc_emailss      r:   Atest_personalization_ccs_setter_filters_out_duplicate_dict_emailszKUnitTests.test_personalization_ccs_setter_filters_out_duplicate_dict_emailsT  r   r<   c                     d | _         t                      }ddd}ddd}||g}||_        |                     |g|j                   d S )Nr   r   r   r   r   )r7   r   r   r   r   s        r:   Otest_personalization_ccs_setter_filters_out_duplicate_dict_emails_ignoring_casezYUnitTests.test_personalization_ccs_setter_filters_out_duplicate_dict_emails_ignoring_case]  r   r<   c                     d | _         t                      }t          dd          gdz  }||_        |                     |d                                         g|j                   d S )Nr   r   r0   r   r_   r   r   r   r3   r5   r   s      r:   ?test_personalization_ccs_setter_filters_out_duplicate_cc_emailszIUnitTests.test_personalization_ccs_setter_filters_out_duplicate_cc_emailsh  r   r<   c                     d | _         t                      }t          dd          }t          dd          }||g|_        |                     |                                g|j                   d S r   r   r   s       r:   Mtest_personalization_ccs_setter_filters_out_duplicate_cc_emails_ignoring_casezWUnitTests.test_personalization_ccs_setter_filters_out_duplicate_cc_emails_ignoring_caseq  sm    ,.ABB 68KLL-.(,,..)1511111r<   c                     d | _         t                      }dddgdz  }||_        |                     |d         g|j                   d S )Nr   r   r   r0   r   r_   r   r   r3   r7   r   
bcc_emailss      r:   Btest_personalization_bccs_setter_filters_out_duplicate_dict_emailszLUnitTests.test_personalization_bccs_setter_filters_out_duplicate_dict_emails{  sV    !8BVXXY\]]
*Q-!&11111r<   c                     d | _         t                      }ddd}ddd}||g}||_        |                     |g|j                   d S )Nr   r   r   r   r   )r7   r   r   r   r   s        r:   Ptest_personalization_bccs_setter_filters_out_duplicate_dict_emails_ignoring_casezZUnitTests.test_personalization_bccs_setter_filters_out_duplicate_dict_emails_ignoring_case  sc    6@TVV	)@J^``!45
)af-----r<   c                     d | _         t                      }t          dd          gdz  }||_        |                     |d                                         g|j                   d S )Nr   r   r0   r   r_   r   r   r   r3   r5   r   s      r:   Atest_personalization_bccs_setter_filters_out_duplicate_bcc_emailszKUnitTests.test_personalization_bccs_setter_filters_out_duplicate_bcc_emails  se    13GHHIAM
*Q-++--.77777r<   c                     d | _         t                      }t          dd          }t          dd          }||g|_        |                     |                                g|j                   d S r   r   r   s       r:   Otest_personalization_bccs_setter_filters_out_duplicate_bcc_emails_ignoring_casezYUnitTests.test_personalization_bccs_setter_filters_out_duplicate_bcc_emails_ignoring_case  sm    /1EFF	!"9;OPP01)--//*AF33333r<   c                    d | _         t                      }t          dd          }|                    |           |                    |           |                                g}|                     ||j                   d S r   )r_   r   r   add_tor5   r3   r   )r7   r   r   expecteds       r:   ;test_personalization_add_to_filters_out_duplicate_to_emailszEUnitTests.test_personalization_add_to_filters_out_duplicate_to_emails  w    ,.ABB		LLNN#15)))))r<   c                    d | _         t                      }t          dd          }|                    |           |                    |           |                                g}|                     ||j                   d S r   )r_   r   r   add_bccr5   r3   r   )r7   r   r   r  s       r:   =test_personalization_add_bcc_filters_out_duplicate_bcc_emailszGUnitTests.test_personalization_add_bcc_filters_out_duplicate_bcc_emails  sw    .0CDD				)			)MMOO$16*****r<   c                    d | _         t                      }t          dd          }|                    |           |                    |           |                                g}|                     ||j                   d S r   )r_   r   r   add_ccr5   r3   r   )r7   r   r   r  s       r:   ;test_personalization_add_cc_filters_out_duplicate_cc_emailszEUnitTests.test_personalization_add_cc_filters_out_duplicate_cc_emails  r  r<   c                 H   d | _         t          ddt          ddi                    t          ddddi          g}t          t	          d	d
          |t          d          ddd          }|                      |j                    t          j	        d                     d S )Nztest+to+0@example.comzExample To 0 Namer    zExample 0 Name)r   r    dynamic_template_dataztest+to+1@example.comzExample To 1 NamezExample 1 Nametest@example.comr   zHi!zHello!z<strong>Hello!</strong>T)rY   rZ   r)   r[   r\   rt   a  {
                "content": [
                    {
                        "type": "text/plain",
                        "value": "Hello!"
                    },
                    {
                        "type": "text/html",
                        "value": "<strong>Hello!</strong>"
                    }
                ],
                "from": {
                    "email": "test@example.com",
                    "name": "Example From Name"
                },
                "personalizations": [
                    {
                        "dynamic_template_data": {
                            "name": "Example 1 Name"
                        },
                        "to": [
                            {
                                "email": "test+to+1@example.com",
                                "name": "Example To 1 Name"
                            }
                        ]
                    },
                    {
                        "dynamic_template_data": {
                            "name": "Example 0 Name"
                        },
                        "to": [
                            {
                                "email": "test+to+0@example.com",
                                "name": "Example To 0 Name"
                            }
                        ]
                    }
                ],
                "subject": "Hi!"
            })
r_   r   r	   r   r   r   r3   r5   r`   ra   )r7   rZ   r   s      r:   test_dynamic_template_dataz$UnitTests.test_dynamic_template_data  s     ,'%8&BR9S%T%TV V V ,'&,.>%?A A A	
	 .0CDDENN'2   	GKMMJ ( ( (+	
 +	
 +	
 +	
 +	
r<   c           
         ddl m}m}m}m}m}m}m}m}m	}	m
}
m}m}m}m}m}m}m}m}m}m}m}m}m}m}m}m}m}m}m}m}m}m } m!}!m"}"m#}#m$}$m%}%m&}&m'}'m(}(m)})m*}*m+}+m,},m-}-m.}.m/}/m0}0m1}1m2}2m3}3m4}4m5}5m6}6m7}7 d | _8         |            }8 |ddd          |8_9         |ddd           |dd	d          g|8_9         |d
dd          |8_:         |ddd           |ddd          g|8_:         |ddd          |8_;         |ddd           |ddd          g|8_;         |dd          |8_<         |ddd          |8_=         |ddd          |8_=         |ddd           |ddd          g|8_=         |dd d          |8_>         |d!d"d          |8_>         |d#d$d           |d%d&d          g|8_>         |	d'd(d          |8_?         |	d)d*d          |8_?         |	d+d*d           |	d,d(d          g|8_?         |
d-d          |8_@         |d.d/d0          |8_9         |d1d2d0           |d3d4d0          g|8_9         |d5d6d0          |8_:         |d7d8d0           |d9d:d0          g|8_:         |d;d<d0          |8_;         |d=d>d0           |d?d@d0          g|8_;         |dAdBd0          |8_=         |dCdDd0          |8_=         |dEdFd0           |dGdHd0          g|8_=         |dIdJd0          |8_>         |dKdLd0          |8_>         |dMdNd0           |dOdPd0          g|8_>         |	dQd(d0          |8_?         |	dRd*d0          |8_?         |	dSd*d0           |	dTd(d0          g|8_?         |
dUd0          |8_@         |dVd0          |8_<         |dWdX          |8_A         |dYdZ          |8_B         |d[          |8_<         ||jC        d\          |8_D         ||jE        d]          |8_D         |d^d_           |d`da          g|8_D         | |db           |dc           |dd           |de           |df                    |8_F         | |dg           |dh           |di           |dj           |dk                     | |dl           |dm           |di           |dj           |dn                    g|8_F         |do          |8_G         |dpdq          |8_H         |drds           |dtdu          g|8_H         |dvdw          |8_=         |dxdy          |8_=         |dzd{           |d|d}          g|8_=         |d~          |8_I         |d          |8_I         |d~           |d          g|8_I         |	dd*          |8_?         |	dd(          |8_?         |	dd(           |	dd*          g|8_?         |
d          |8_@         |d          |8_J         | |d0           |g d                    |8_K         |d          |8_L         |            }9 |d |d                    |9_M         |d          |9_N         | d          |9_O         |!d          |9_P         |"d          |9_Q         |#d |$d           |%d                    |9_R         |&d          |9_S         |'d |(d           |)d                    |9_T        |9|8_U         |*            }: |+dd          |:_V         |0d |1d                    |:_W         |,d |-d           |.d           |/d                    |:_X         |2d |3d           |4d           |5d           |6d           |7d                    |:_Y        |:|8_Z        | [                     |8j\                    t          j^        d                     d S )Nr   )7r   r   r   r   r   r   r   Header	CustomArgSendAtr   MimeTyper   r@   r>   r?   rA   rB   
TemplateIdSectionrm   CategoryrP   r   r-   r.   
IpPoolNameMailSettingsBccSettingsBccSettingsEmailBypassBounceManagementBypassListManagementBypassSpamManagementBypassUnsubscribeManagementFooterSettings
FooterText
FooterHtmlSandBoxMode	SpamCheckSpamThresholdSpamUrlr   r   SubscriptionTrackingSubscriptionTextSubscriptionHtmlSubscriptionSubstitutionTagOpenTrackingOpenTrackingSubstitutionTag
Ganalytics	UtmSource	UtmMediumUtmTerm
UtmContentUtmCampaignztest1@example.comzExample User1r   ztest2@example.comzExample User2ztest3@example.comzExample User3ztest4@example.comzExample User4ztest5@example.comzExample User5ztest6@example.comzExample User6ztest7@example.comzExample User7ztest8@example.comzExample User8ztest9@example.comzExample User9zSending with SendGrid is Fun 0zX-Test1Test1zX-Test2Test2zX-Test3Test3zX-Test4Test4z%name1%rr   z%city1%zExample City 1z%name2%zExample Name 2z%city2%zExample City 2
marketing1truetransactional1false
marketing2transactional2i Wztest10@example.comzExample User10r/   ztest11@example.comzExample User11ztest12@example.comzExample User12ztest13@example.comzExample User13ztest14@example.comzExample User14ztest15@example.comzExample User15ztest16@example.comzExample User16ztest17@example.comzExample User17ztest18@example.comzExample User18zX-Test5Test5zX-Test6Test6zX-Test7Test7zX-Test8Test8z%name3%zExample Name 3z%city3%zExample City 3z%name4%zExample Name 4z%city4%zExample City 4
marketing3transactional3
marketing4transactional4i WzSending with SendGrid is Fun 1zhelp@twilio.comzTwilio SendGridzhelp_reply@twilio.comzTwilio SendGrid ReplyzSending with SendGrid is Fun 2r   r   ztext/calendarzParty Time!!ztext/customzParty Time 2!!zbase64 encoded content 1zbalance_001.pdfrD   rE   zContent ID 1zbase64 encoded content 2z
banner.pngz	image/pnginlinezContent ID 2zbase64 encoded content 3zbanner2.pngzContent ID 3z$13b8f94f-bcae-4ec6-b752-70d6cb59f932z
%section1%zSubstitution for Section 1 Tagz
%section2%zSubstitution for Section 2 Tagz
%section3%zSubstitution for Section 3 TagzX-Test9Test9zX-Test10Test10zX-Test11Test11zX-Test12Test12z
Category 1z
Category 2
marketing5transactional5
marketing6transactional6i W HkJ5yLYULb7Rj8GKSx7u025ouWVlMgAi)r/   r0   r1      zIP Pool NameFzbcc@twilio.comTw00tz<string>w00t!<strong>   zhttps://example.comopen_trackingGoodbyez<strong>Goodbye!</strong>unsubscribe
utm_source
utm_mediumutm_termutm_contentutm_campaigna+  {
                "asm": {
                    "group_id": 1,
                    "groups_to_display": [
                        1,
                        2,
                        3,
                        4
                    ]
                },
                "attachments": [
                    {
                        "content": "base64 encoded content 3",
                        "content_id": "Content ID 3",
                        "disposition": "inline",
                        "filename": "banner2.png",
                        "type": "image/png"
                    },
                    {
                        "content": "base64 encoded content 2",
                        "content_id": "Content ID 2",
                        "disposition": "inline",
                        "filename": "banner.png",
                        "type": "image/png"
                    },
                    {
                        "content": "base64 encoded content 1",
                        "content_id": "Content ID 1",
                        "disposition": "attachment",
                        "filename": "balance_001.pdf",
                        "type": "application/pdf"
                    }
                ],
                "batch_id": "HkJ5yLYULb7Rj8GKSx7u025ouWVlMgAi",
                "categories": [
                    "Category 2",
                    "Category 1",
                    "Category 2",
                    "Category 1"
                ],
                "content": [
                    {
                        "type": "text/plain",
                        "value": "and easy to do anywhere, even with Python"
                    },
                    {
                        "type": "text/html",
                        "value": "<strong>and easy to do anywhere, even with Python</strong>"
                    },
                    {
                        "type": "text/calendar",
                        "value": "Party Time!!"
                    },
                    {
                        "type": "text/custom",
                        "value": "Party Time 2!!"
                    }
                ],
                "custom_args": {
                    "marketing5": "false",
                    "marketing6": "true",
                    "transactional5": "true",
                    "transactional6": "false"
                },
                "from": {
                    "email": "help@twilio.com",
                    "name": "Twilio SendGrid"
                },
                "headers": {
                    "X-Test10": "Test10",
                    "X-Test11": "Test11",
                    "X-Test12": "Test12",
                    "X-Test9": "Test9"
                },
                "ip_pool_name": "IP Pool Name",
                "mail_settings": {
                    "bcc": {
                        "email": "bcc@twilio.com",
                        "enable": false
                    },
                    "bypass_bounce_management": {
                        "enable": false
                    },
                    "bypass_list_management": {
                        "enable": false
                    },
                    "bypass_spam_management": {
                        "enable": false
                    },
                    "bypass_unsubscribe_management": {
                        "enable": false
                    },
                    "footer": {
                        "enable": true,
                        "html": "<string>w00t!<strong>",
                        "text": "w00t"
                    },
                    "sandbox_mode": {
                        "enable": true
                    },
                    "spam_check": {
                        "enable": true,
                        "post_to_url": "https://example.com",
                        "threshold": 5
                    }
                },
                "personalizations": [
                    {
                        "bcc": [
                            {
                                "email": "test7@example.com",
                                "name": "Example User7"
                            },
                            {
                                "email": "test8@example.com",
                                "name": "Example User8"
                            },
                            {
                                "email": "test9@example.com",
                                "name": "Example User9"
                            }
                        ],
                        "cc": [
                            {
                                "email": "test4@example.com",
                                "name": "Example User4"
                            },
                            {
                                "email": "test5@example.com",
                                "name": "Example User5"
                            },
                            {
                                "email": "test6@example.com",
                                "name": "Example User6"
                            }
                        ],
                        "custom_args": {
                            "marketing1": "true",
                            "marketing2": "false",
                            "transactional1": "false",
                            "transactional2": "true"
                        },
                        "headers": {
                            "X-Test1": "Test1",
                            "X-Test2": "Test2",
                            "X-Test3": "Test3",
                            "X-Test4": "Test4"
                        },
                        "send_at": 1461775051,
                        "subject": "Sending with SendGrid is Fun 0",
                        "substitutions": {
                            "%city1%": "Example City 1",
                            "%city2%": "Example City 2",
                            "%name1%": "Example Name 1",
                            "%name2%": "Example Name 2"
                        },
                        "to": [
                            {
                                "email": "test1@example.com",
                                "name": "Example User1"
                            },
                            {
                                "email": "test2@example.com",
                                "name": "Example User2"
                            },
                            {
                                "email": "test3@example.com",
                                "name": "Example User3"
                            }
                        ]
                    },
                    {
                        "bcc": [
                            {
                                "email": "test16@example.com",
                                "name": "Example User16"
                            },
                            {
                                "email": "test17@example.com",
                                "name": "Example User17"
                            },
                            {
                                "email": "test18@example.com",
                                "name": "Example User18"
                            }
                        ],
                        "cc": [
                            {
                                "email": "test13@example.com",
                                "name": "Example User13"
                            },
                            {
                                "email": "test14@example.com",
                                "name": "Example User14"
                            },
                            {
                                "email": "test15@example.com",
                                "name": "Example User15"
                            }
                        ],
                        "custom_args": {
                            "marketing3": "true",
                            "marketing4": "false",
                            "transactional3": "false",
                            "transactional4": "true"
                        },
                        "headers": {
                            "X-Test5": "Test5",
                            "X-Test6": "Test6",
                            "X-Test7": "Test7",
                            "X-Test8": "Test8"
                        },
                        "send_at": 1461775052,
                        "subject": "Sending with SendGrid is Fun 1",
                        "substitutions": {
                            "%city3%": "Example City 3",
                            "%city4%": "Example City 4",
                            "%name3%": "Example Name 3",
                            "%name4%": "Example Name 4"
                        },
                        "to": [
                            {
                                "email": "test10@example.com",
                                "name": "Example User10"
                            },
                            {
                                "email": "test11@example.com",
                                "name": "Example User11"
                            },
                            {
                                "email": "test12@example.com",
                                "name": "Example User12"
                            }
                        ]
                    }
                ],
                "reply_to": {
                    "email": "help_reply@twilio.com",
                    "name": "Twilio SendGrid Reply"
                },
                "sections": {
                    "%section1%": "Substitution for Section 1 Tag",
                    "%section2%": "Substitution for Section 2 Tag",
                    "%section3%": "Substitution for Section 3 Tag"
                },
                "send_at": 1461775053,
                "subject": "Sending with SendGrid is Fun 2",
                "template_id": "13b8f94f-bcae-4ec6-b752-70d6cb59f932",
                "tracking_settings": {
                    "click_tracking": {
                        "enable": true,
                        "enable_text": false
                    },
                    "ganalytics": {
                        "enable": true,
                        "utm_campaign": "utm_campaign",
                        "utm_content": "utm_content",
                        "utm_medium": "utm_medium",
                        "utm_source": "utm_source",
                        "utm_term": "utm_term"
                    },
                    "open_tracking": {
                        "enable": true,
                        "substitution_tag": "open_tracking"
                    },
                    "subscription_tracking": {
                        "enable": true,
                        "html": "<strong>Goodbye!</strong>",
                        "substitution_tag": "unsubscribe",
                        "text": "Goodbye"
                    }
                }
            })_r2   r   r   r   r   r   r   r   r  r  r  r   r  r   r@   r>   r?   rA   rB   r  r  rm   r  rP   r   r-   r.   r  r  r  r  r  r  r   r!  r"  r#  r$  r%  r&  r'  r(  r   r   r)  r*  r+  r,  r-  r.  r/  r0  r1  r2  r3  r4  r_   r!   ccbccr)   headersubstitution
custom_argsend_atrY   reply_totextr&   htmlrE   template_idsectioncategorybatch_idasmip_pool_namebcc_settingsbypass_bounce_managementbypass_list_managementbypass_spam_managementbypass_unsubscribe_managementfooter_settingssandbox_mode
spam_checkmail_settingsclick_trackingrU  subscription_tracking
ganalyticstracking_settingsr3   r5   r`   ra   );r7   r   r   r   r   r   r   r   r  r  r  r   r  r   r@   r>   r?   rA   rB   r  r  rm   r  rP   r   r-   r.   r  r  r  r  r  r  r   r!  r"  r#  r$  r%  r&  r'  r(  r   r   r)  r*  r+  r,  r-  r.  r/  r0  r1  r2  r3  r4  r   rt  rx  s;                                                              r:   test_kitchen_sinkzUnitTests.test_kitchen_sink  s   	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D $&& R+_BBB
B"Oq999B"Oq999


 R+_BBB
B"Oq999B"Oq999


 c-!DDDC#_:::C#_:::

 "'"BaHHH	7a888	7a888F9g+++F9g+++

  ,|I7G1MMM+|I7G1MMML$4:::L$4::: 

 'Y|VqAAA&Y'7AFFFIlGq111I&!444

 !&q111R,.>!DDD
B#%5;;;B#%5;;;


 R,.>!DDD
B#%5;;;B#%5;;;


 c.0@AFFFC$&6!<<<C$&6!<<<

  	7a888	7a888F9g+++F9g+++

  ,|I7G1MMM+|I7G1MMML$4:::L$4::: 

 'Y|VqAAA&Y'7AFFFIlGq111I&!444

 !&q111!'"BaHHH "T"35FGG"7#:<STT!'"BCC!'M79 9 "'MHJ J GO^44GM#344

 (ZK233H&''H&''K%%In%%' ' J677&&%%H%%	.))+ + J677''%%H%%	.))+ +
 )j24 4 "':< < GL"BCCGL"BCC

  	733
H55F:x((F:x((

 $8L11#8L11H\""H\""

 'Y|W==&Y'7@@IlF++I&00

 !&,,"7#EFFc''!**oolll&C&CDD)z.99$%0[##$455&7 &7"1G1G1N1N./C/CE/J/J,/C/CE/J/J,6Q6QRW6X6X3(6**V$$jj1H&I&I)K )K%%0[%6%6"#,9--""GG,A$B$B$D $D  -,,..+8=u+E+E(*6,--o>>+@ +@'2F2FY''899''66	38 38/
 (2zIl##Il##GJJ}%%K''() ()$ %6!GKMMJ P P PS	
 S	
 S	
 S	
 S	
r<   c                 v   ddl m}m}m}m}m}m} d | _         | |dd           |dd           |d           |d           |d	          
          }t          dddddddddddddgdddddddd	          |_	        | 
                     |j                    t          j        d                     d S )Nr   rU   r   r   r"   r#   r$   r   r   rX   z$ 239.85zNew Line Sneakerszhttps://marketing-image-production.s3.amazonaws.com/uploads/8dda1131320a6d978b515cc04ed479df259a458d5d45d58b6b381cae0bf9588113e80ef912f69e8c4cc1ef1a0297e8eefdb7b270064cc046b79a44e21b811802.pngz$ 79.95)rd  imagepricezOld Line Sneakerszhttps://marketing-image-production.s3.amazonaws.com/uploads/3629f54390ead663d4eb7c53702e492de63299d7c5f7239efdc693b09b9b28c82c924225dcd8dcb65732d5ca7b7b753c5f17e056405bbd4596e4e63a96ae5018.pngzBlue Line Sneakerszhttps://marketing-image-production.s3.amazonaws.com/uploads/00731ed18eff0ad5da890d876c456c3124a4e44cb48196533e9b95fb2b959b7194c2dc7637b788341d1ff4f88d1dc88e23f7e3704726d313c57f350911dd2bd0.pngTzSample Namez1234 Fake St.zApt. 123PlaceCO80202)	totalitemsreceiptr    	address01	address02citystatezipa
  {
                "content": [
                    {
                        "type": "text/plain",
                        "value": "and easy to do anywhere, even with Python"
                    },
                    {
                        "type": "text/html",
                        "value": "<strong>and easy to do anywhere, even with Python</strong>"
                    }
                ],
                "from": {
                    "email": "test+from@example.com",
                    "name": "Example From Name"
                },
                "personalizations": [
                    {
                        "dynamic_template_data": {
                            "address01": "1234 Fake St.",
                            "address02": "Apt. 123",
                            "city": "Place",
                            "items": [
                                {
                                    "image": "https://marketing-image-production.s3.amazonaws.com/uploads/8dda1131320a6d978b515cc04ed479df259a458d5d45d58b6b381cae0bf9588113e80ef912f69e8c4cc1ef1a0297e8eefdb7b270064cc046b79a44e21b811802.png",
                                    "price": "$ 79.95",
                                    "text": "New Line Sneakers"
                                },
                                {
                                    "image": "https://marketing-image-production.s3.amazonaws.com/uploads/3629f54390ead663d4eb7c53702e492de63299d7c5f7239efdc693b09b9b28c82c924225dcd8dcb65732d5ca7b7b753c5f17e056405bbd4596e4e63a96ae5018.png",
                                    "price": "$ 79.95",
                                    "text": "Old Line Sneakers"
                                },
                                {
                                    "image": "https://marketing-image-production.s3.amazonaws.com/uploads/00731ed18eff0ad5da890d876c456c3124a4e44cb48196533e9b95fb2b959b7194c2dc7637b788341d1ff4f88d1dc88e23f7e3704726d313c57f350911dd2bd0.png",
                                    "price": "$ 79.95",
                                    "text": "Blue Line Sneakers"
                                }
                            ],
                            "name": "Sample Name",
                            "receipt": true,
                            "state": "CO",
                            "total": "$ 239.85",
                            "zip": "80202"
                        },
                        "to": [
                            {
                                "email": "test+to@example.com",
                                "name": "Example To Name"
                            }
                        ]
                    }
                ],
                "subject": "Sending with SendGrid is Fun"
            })r2   r   r   r   r   rV   rW   r_   r	   r  r3   r5   r`   ra   rb   s           r:   >test_single_email_to_a_single_recipient_with_dynamic_templateszHUnitTests.test_single_email_to_a_single_recipient_with_dynamic_templates  s   	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J$t35HIIb.0ABBG:;;//; =  =$LN NO O O )< 0 `&  0 `&  1 `& " !(#3=
 =
 ) )%6 	GKMMJ 5 5 58	
 8	
 8	
 8	
 8	
r<   c                 B   d| _         t                      }t          d          |_        d|_        t                      }|                    t          d                     |                    |           	 |                    t          dd                     |                    t          dd                     | 
                    t          j        |                                d	          d
           |                     d           dS # t          $ r Y dS w xY w)z7Tests if including SendGrid API will throw an ExceptionNr  z,Hello World from the SendGrid Python Libraryr   zsome SG.2123b1B.1212lBaC herer   z8<html><body>some SG.Ba2BlJSDba.232Ln2 here</body></html>T)	sort_keysa-  {"content": [{"type": "text/plain", "value": "some text here"}, {"type": "text/html", "value": "<html><body>some text here</body></html>"}], "from": {"email": "test@example.com"}, "personalizations": [{"to": [{"email": "test@example.com"}]}], "subject": "Hello World from the SendGrid Python Library"}z/Should have failed as SendGrid API key included)max_diffr   r
   rY   r)   r   r  add_personalizationadd_contentr   r3   r`   r   r5   fail	Exception)r7   r   personalizations      r:   test_sendgrid_api_keyzUnitTests.test_sendgrid_api_keyV  sK    vv 233E)++u%788999  111	I 35 56 6 6 NP PQ Q Q
 
HHJJ"$ $ $M	
 
 
$ IIGHHHHH  	 	 	DD	s   7BD 
DDc           	      J   ddl m}m}m}m}m}m} d | _         | |dd           |dd           |d           |d           |d	          
          }t          ddd          |_	        | 
                     |j                    t          j        d                     d S )Nr   rU   r   r   r"   r#   r$   r   r   rX   z%city%u
   Αθήναr/   r5  ue  {
                "content": [
                    {
                        "type": "text/plain",
                        "value": "and easy to do anywhere, even with Python"
                    },
                    {
                        "type": "text/html",
                        "value": "<strong>and easy to do anywhere, even with Python</strong>"
                    }
                ],
                "from": {
                    "email": "test+from@example.com",
                    "name": "Example From Name"
                },
                "personalizations": [
                    {
                        "to": [
                            {
                                "email": "test+to@example.com",
                                "name": "Example To Name"
                            }
                        ]
                    },
                    {
                        "substitutions": {
                            "%city%": "Αθήνα"
                        }
                    }
                ],
                "subject": "Sending with SendGrid is Fun"
            })r2   r   r   r   r   rV   rW   r_   r   r`  r3   r5   r`   ra   rb   s           r:   +test_unicode_values_in_substitutions_helperz5UnitTests.test_unicode_values_in_substitutions_helper  s3   	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J$t35HIIb.0ABBG:;;//; =  =$LN NO O O  ,HmqIIIGKMMJ   "	
 "	
 "	
 "	
 "	
r<   c           
      ~    |                      t          t          dt          t	          d                               d S )Nr/      )r   r   r   listrange)r7   s    r:   test_asm_display_group_limitz&UnitTests.test_asm_display_group_limit  s.    *c1d599oo>>>>>r<   c                     t                      }t          dd          |_        |                     |                                ddddi           d S )NFru  )enableenable_text)r   r   ru  r3   r5   )r7   rx  s     r:   test_disable_trackingzUnitTests.test_disable_tracking  sb    ,..+8+F+F(!!##%FFG	
 	
 	
 	
 	
r<   c                     ddl m}m}  |            } |d          |_        |                     |                                dddii           d S )Nr   )r  r  Trn  r  )r2   r  r  rn  r3   r5   )r7   r  r  rt  s       r:   test_bypass_list_managementz%UnitTests.test_bypass_list_management  s{    NNNNNNNN$/C/CD/I/I,(d+	
 	
 	
 	
 	
r<   c                     ddl m}m}m}m}  |            } |d          |_         |d          |_         |d          |_        |                     |	                                ddiddiddid           d S )Nr   )r  r  r   r!  Tr  )rm  ro  rp  )
r2   r  r  r   r!  rm  ro  rp  r3   r5   )r7   r  r  r   r!  rt  s         r:   test_v3_bypass_filtersz UnitTests.test_v3_bypass_filters  s    	
 	
 	
 	
 	
 	
 	
 	
 	
 	
 	
 	
 %1G1G1M1M./C/CD/I/I,6Q6QRV6W6W3 d- d+ d2
 
	
 	
 	
 	
 	
r<   N);__name__
__module____qualname__r;   rN   rS   rc   re   rk   ro   ru   r|   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r
  r  r  ry  r  r  r  r  r  r  r   r<   r:   r+   r+   7   s       H H HC C C.( ( (*
 *
 *
X,
 ,
 ,
\2
 2
 2
h2
 2
 2
hQ
 Q
 Q
f
 
 
(+
 +
 +
Z+
 +
 +
\
 
 
(
 
 
(
 
 
(
 
 
(
 
 
(
 
 
,S S S$^ ^ ^&N N N&O O O"O O OO O OO O OO O O$2 2 2	2 	2 	29 9 92 2 2	2 	2 	24 4 4	4 	4 	40 0 0	, 	, 	,6 6 6	2 	2 	20 0 0	, 	, 	,6 6 62 2 22 2 2	. 	. 	.8 8 84 4 4
* 
* 
*
+ 
+ 
+
* 
* 
*>
 >
 >
@l
 l
 l
^_
 _
 _
B,I ,I ,I\/
 /
 /
b? ? ?
 
 

 
 

 
 
 
 
r<   r+   )r`   unittestemail.messager   ImportErrorr   r   Messager2   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   ry   r   rz   TestCaser+   r  r<   r:   <module>r     s    #******* # # #?LLL#
                                  j
 0:
 !@	
 	

 &%	
 	

  Q	
 	
 )#  2- 	
	 .;< < 1 1 -@o
 o
 o
 o
 o
! o
 o
 o
 o
 o
s    &&