@ -9,8 +9,7 @@ from apistar_mail.exc import MailUnicodeDecodeError, BadHeaderError
 
		
	
		
			
				
 
		
	
		
			
				import  pytest  
		
	
		
			
				
 
		
	
		
			
				settings  =  {  
		
	
		
			
				    ' MAIL ' :  { 
 
		
	
		
			
				test_mail_options  =  {  
		
	
		
			
				    ' MAIL_SERVER ' :  ' smtp.example.com ' , 
 
		
	
		
			
				    ' MAIL_USERNAME ' :  ' fake@example.com ' , 
 
		
	
		
			
				    ' MAIL_PASSWORD ' :  ' secret ' , 
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -18,7 +17,6 @@ settings = {
 
		
	
		
			
				    ' MAIL_USE_TLS ' :  True , 
 
		
	
		
			
				    ' MAIL_SUPPRESS_SEND ' :  True , 
 
		
	
		
			
				    ' MAIL_DEFAULT_SENDER ' :  ' fake@example.com ' 
 
		
	
		
			
				    } 
 
		
	
		
			
				}  
		
	
		
			
				
 
		
	
		
			
				
 
		
	
	
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
				
			
			@ -400,7 +398,7 @@ def test_message_charset():
 
		
	
		
			
				
 
		
	
		
			
				
 
		
	
		
			
				def  test_empty_subject_header ( ) :  
		
	
		
			
				    mail  =  Mail ( e tting s) 
 
		
	
		
			
				    mail  =  Mail ( * * te st_mail_op tio ns) 
 
		
	
		
			
				    msg  =  Message ( sender = " from@example.com " , 
 
		
	
		
			
				                  recipients = [ " foo@bar.com " ] ) 
 
		
	
		
			
				    msg . body  =  " normal ascii text " 
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -411,13 +409,13 @@ def test_empty_subject_header():
 
		
	
		
			
				def  test_message_default_sender ( ) :  
		
	
		
			
				    msg  =  Message ( recipients = [ " foo@bar.com " ] ) 
 
		
	
		
			
				    msg . body  =  " normal ascii text " 
 
		
	
		
			
				    mail  =  Mail ( e tting s) 
 
		
	
		
			
				    mail  =  Mail ( * * te st_mail_op tio ns) 
 
		
	
		
			
				    mail . send ( msg ) 
 
		
	
		
			
				    assert  msg . sender  ==  ' fake@example.com ' 
 
		
	
		
			
				
 
		
	
		
			
				
 
		
	
		
			
				def  test_mail_send_message ( ) :  
		
	
		
			
				    mail  =  Mail ( e tting s) 
 
		
	
		
			
				    mail  =  Mail ( * * te st_mail_op tio ns) 
 
		
	
		
			
				    mail . send  =  MagicMock ( ) 
 
		
	
		
			
				    mail . send_message ( sender = " from@example.com " , 
 
		
	
		
			
				                      recipients = [ " foo@bar.com " ] , 
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -426,7 +424,7 @@ def test_mail_send_message():
 
		
	
		
			
				
 
		
	
		
			
				
 
		
	
		
			
				def  test_message_ascii_attachments_config ( ) :  
		
	
		
			
				    mail  =  Mail ( e tting s) 
 
		
	
		
			
				    mail  =  Mail ( * * te st_mail_op tio ns) 
 
		
	
		
			
				    mail . mail_ascii_attachments  =  True 
 
		
	
		
			
				    msg  =  Message ( sender = " from@example.com " , 
 
		
	
		
			
				                  subject = " subject " , 
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -447,7 +445,7 @@ def test_message_as_bytes():
 
		
	
		
			
				
 
		
	
		
			
				@patch ( ' apistar_mail.mail.smtplib.SMTP ' )  
		
	
		
			
				def  test_connection_configure_host_non_ssl ( mock_smtp ) :  
		
	
		
			
				    mail  =  Mail ( e tting s) 
 
		
	
		
			
				    mail  =  Mail ( * * te st_mail_op tio ns) 
 
		
	
		
			
				    mail . mail_suppress_send  =  False 
 
		
	
		
			
				    mail . mail_use_tls  =  True 
 
		
	
		
			
				    mock_smtp . return_value  =  MagicMock ( ) 
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -459,7 +457,7 @@ def test_connection_configure_host_non_ssl(mock_smtp):
 
		
	
		
			
				
 
		
	
		
			
				@patch ( ' apistar_mail.mail.smtplib.SMTP_SSL ' )  
		
	
		
			
				def  test_connection_configure_host_ssl ( mock_smtp_ssl ) :  
		
	
		
			
				    mail  =  Mail ( e tting s) 
 
		
	
		
			
				    mail  =  Mail ( * * te st_mail_op tio ns) 
 
		
	
		
			
				    mail . mail_suppress_send  =  False 
 
		
	
		
			
				    mail . mail_use_tls  =  False 
 
		
	
		
			
				    mail . mail_use_ssl  =  True 
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -469,7 +467,7 @@ def test_connection_configure_host_ssl(mock_smtp_ssl):
 
		
	
		
			
				
 
		
	
		
			
				
 
		
	
		
			
				def  test_connection_send_message ( ) :  
		
	
		
			
				    mail  =  Mail ( e tting s) 
 
		
	
		
			
				    mail  =  Mail ( * * te st_mail_op tio ns) 
 
		
	
		
			
				    with  mail . connect ( )  as  conn : 
 
		
	
		
			
				        conn . send  =  MagicMock ( ) 
 
		
	
		
			
				        conn . send_message ( sender = " from@example.com " , 
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -480,7 +478,7 @@ def test_connection_send_message():
 
		
	
		
			
				
 
		
	
		
			
				@patch ( ' apistar_mail.mail.smtplib.SMTP ' )  
		
	
		
			
				def  test_connection_send_single ( mock_smtp ) :  
		
	
		
			
				    mail  =  Mail ( e tting s) 
 
		
	
		
			
				    mail  =  Mail ( * * te st_mail_op tio ns) 
 
		
	
		
			
				    mail . mail_suppress_send  =  False 
 
		
	
		
			
				    msg  =  Message ( sender = " from@example.com " , 
 
		
	
		
			
				                  recipients = [ " foo@bar.com " ] , 
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -494,7 +492,7 @@ def test_connection_send_single(mock_smtp):
 
		
	
		
			
				
 
		
	
		
			
				
 
		
	
		
			
				def  test_connection_send_ascii_recipient_single ( ) :  
		
	
		
			
				    mail  =  Mail ( e tting s) 
 
		
	
		
			
				    mail  =  Mail ( * * te st_mail_op tio ns) 
 
		
	
		
			
				    msg  =  Message ( sender = " from@example.com " , 
 
		
	
		
			
				                  recipients = [ " foo@bar.com " ] , 
 
		
	
		
			
				                  body = " normal ascii text " ) 
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -506,7 +504,7 @@ def test_connection_send_ascii_recipient_single():
 
		
	
		
			
				
 
		
	
		
			
				
 
		
	
		
			
				def  test_connection_send_non_ascii_recipient_single ( ) :  
		
	
		
			
				    mail  =  Mail ( e tting s) 
 
		
	
		
			
				    mail  =  Mail ( * * te st_mail_op tio ns) 
 
		
	
		
			
				    with  mail . connect ( )  as  conn : 
 
		
	
		
			
				        with  patch . object ( conn ,  ' host ' )  as  host : 
 
		
	
		
			
				            msg  =  Message ( subject = " testing " , 
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -526,7 +524,7 @@ def test_connection_send_non_ascii_recipient_single():
 
		
	
		
			
				
 
		
	
		
			
				@patch ( ' apistar_mail.mail.smtplib.SMTP ' )  
		
	
		
			
				def  test_connection_send_many ( mock_smtp ) :  
		
	
		
			
				    mail  =  Mail ( e tting s) 
 
		
	
		
			
				    mail  =  Mail ( * * te st_mail_op tio ns) 
 
		
	
		
			
				    mail . mail_suppress_send  =  False 
 
		
	
		
			
				    mail . mail_max_emails  =  50 
 
		
	
		
			
				    mock_smtp . return_value  =  MagicMock ( spec = SMTP ) 
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -545,7 +543,7 @@ def test_connection_send_many(mock_smtp):
 
		
	
		
			
				
 
		
	
		
			
				
 
		
	
		
			
				def  test_bad_header_subject ( ) :  
		
	
		
			
				    mail  =  Mail ( e tting s) 
 
		
	
		
			
				    mail  =  Mail ( * * te st_mail_op tio ns) 
 
		
	
		
			
				    msg  =  Message ( subject = " testing \r \n " , 
 
		
	
		
			
				                  body = " testing " , 
 
		
	
		
			
				                  recipients = [ " to@example.com " ] ) 
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -555,7 +553,7 @@ def test_bad_header_subject():
 
		
	
		
			
				
 
		
	
		
			
				
 
		
	
		
			
				def  test_bad_header_subject_whitespace ( ) :  
		
	
		
			
				    mail  =  Mail ( e tting s) 
 
		
	
		
			
				    mail  =  Mail ( * * te st_mail_op tio ns) 
 
		
	
		
			
				    msg  =  Message ( subject = " \t \r \n " , 
 
		
	
		
			
				                  body = " testing " , 
 
		
	
		
			
				                  recipients = [ " to@example.com " ] ) 
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -570,7 +568,7 @@ def test_bad_header_subject_with_no_trailing_whitespace():
 
		
	
		
			
				
 
		
	
		
			
				    This  is  a  bit  of  a  strange  test  but  we  aren ' t changing the bad_header check from flask_mail 
 
		
	
		
			
				    """ 
 
		
	
		
			
				    mail  =  Mail ( e tting s) 
 
		
	
		
			
				    mail  =  Mail ( * * te st_mail_op tio ns) 
 
		
	
		
			
				    msg  =  Message ( subject = " testing \r \n testing " , 
 
		
	
		
			
				                  body = " testing " , 
 
		
	
		
			
				                  recipients = [ " to@example.com " ] ) 
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -580,7 +578,7 @@ def test_bad_header_subject_with_no_trailing_whitespace():
 
		
	
		
			
				
 
		
	
		
			
				
 
		
	
		
			
				def  test_bad_header_subject_trailing_whitespace ( ) :  
		
	
		
			
				    mail  =  Mail ( e tting s) 
 
		
	
		
			
				    mail  =  Mail ( * * te st_mail_op tio ns) 
 
		
	
		
			
				    msg  =  Message ( subject = " testing \r \n \t " , 
 
		
	
		
			
				                  body = " testing " , 
 
		
	
		
			
				                  recipients = [ " to@example.com " ] ) 
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -590,7 +588,7 @@ def test_bad_header_subject_trailing_whitespace():
 
		
	
		
			
				
 
		
	
		
			
				
 
		
	
		
			
				def  test_bad_header_with_a_newline ( ) :  
		
	
		
			
				    mail  =  Mail ( e tting s) 
 
		
	
		
			
				    mail  =  Mail ( * * te st_mail_op tio ns) 
 
		
	
		
			
				    msg  =  Message ( subject = " \n testing \r \n testing " , 
 
		
	
		
			
				                  body = " testing " , 
 
		
	
		
			
				                  recipients = [ " to@example.com " ] ) 
 
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
			
			@ -600,7 +598,7 @@ def test_bad_header_with_a_newline():
 
		
	
		
			
				
 
		
	
		
			
				
 
		
	
		
			
				def  test_bad_header_with_newline_in_sender ( ) :  
		
	
		
			
				    mail  =  Mail ( e tting s) 
 
		
	
		
			
				    mail  =  Mail ( * * te st_mail_op tio ns) 
 
		
	
		
			
				    msg  =  Message ( subject = " testing " , 
 
		
	
		
			
				                  body = " testing " , 
 
		
	
		
			
				                  sender = ' me \n @example.com ' ,