
    Yf                        d dl mZ d dlZd dlZd dlmZ d dlmZmZ d dl	m
Z
mZmZ d dlmZ d dlmZ  G d d	ej                  ZdS )
    )annotationsN)Message)BytesIOStringIO)IOAnyStrCallable)bounce)unittestc                  :    e Zd ZdZddZddZddZddZddZdS )BounceTestsz#
    Bounce message generation
    returnNonec                   t          j        t          d          dd          \  }}}|                     |d           |                     |d           t          j                                        }|                    t          |                    d                              }|                     |d         d           |                     |d         d	           |                     |d
         d           dS )zN
        L{twisted.mail.bounce.generateBounce} can accept L{unicode}.
        zRFrom: Moshe Zadka <moshez@example.com>
To: nonexistent@example.org
Subject: test

moshez@example.comnonexistent@example.org       moshez@example.comutf-8ToFrompostmaster@example.orgsubject)Returned Mail: see transcript for detailsN)	r
   generateBouncer   assertEqualemailparserParserparsedecodeselffromAddresstosemailParsermesss         O/var/www/html/env/lib/python3.11/site-packages/twisted/mail/test/test_bounce.pytest_bounceMessageUnicodez%BounceTests.test_bounceMessageUnicode   s     $2  !%
 
R 	c***2333l))++  !((7*;*;!<!<==d%9:::f'?@@@i*UVVVVVr   c                   t          j        t          d          dd          \  }}}|                     |d           |                     |d           t          j                                        }|                    t          |	                    d                              }|                     |d         d           |                     |d         d	           |                     |d
         d           dS )zL
        L{twisted.mail.bounce.generateBounce} can accept L{bytes}.
        R   From: Moshe Zadka <moshez@example.com>
To: nonexistent@example.org
Subject: test

r      nonexistent@example.orgr   r   r   r   r   r   r   r   N)
r
   r   r   r   r   r   r   r    r   r!   r"   s         r)   test_bounceMessageBytesz#BounceTests.test_bounceMessageBytes,   s     $2  "&
 
R 	c***2333l))++  !((7*;*;!<!<==d%9:::f'?@@@i*UVVVVVr   c                   t          j        t          d          ddd          \  }}}|                     |d           |                     |d           t          j                                        }|                    t          |	                    d                              }|                     |d         d           |                     |d	         d
           |                     |d         d           | 
                    |                                           |                                }|                     |d                                         d           dS )z\
        Pass a custom transcript message to L{twisted.mail.bounce.generateBounce}.
        r,   r   r-   zCustom transcriptr   r   r   r   r   r   r   r   r   zCustom transcript
N)r
   r   r   r   r   r   r   r    r   r!   
assertTrueis_multipartget_payload)r#   r$   r%   r&   r'   r(   partss          r)   "test_bounceMessageCustomTranscriptz.BounceTests.test_bounceMessageCustomTranscriptD   s[    $2  "&
 
R 	c***2333l))++  !((7*;*;!<!<==d%9:::f'?@@@i*UVVV))++,,,#//11!H  ""!	
 	
 	
 	
 	
r   headerr   messageioTypeCallable[[AnyStr], IO[AnyStr]]c                
   t          j         |||z             dd          \  }}}t          j                                        }|                    t          |                    d                              }|                     |d         d           |                     |d         d           |                     |d         d           | 	                    |
                                           |                                }	|	d	                                         }
t          |t                    r|                    d          }n|}|
d
                                         }|                     |dz   |           dS )zU
        Pass a really big message to L{twisted.mail.bounce.generateBounce}.
        r   r   r   r   r   r   r   r      r   
N)r
   r   r   r   r   r    r   r!   r   r0   r1   r2   
isinstancebytes)r#   r5   r6   r7   r$   r%   r&   r'   r(   r3   innerMessagemessageTextpls                r)   _bounceBigMessagezBounceTests._bounceBigMessagec   se    $2F6G#$$&:<U
 
R l))++  !((7*;*;!<!<==d%9:::f'?@@@i*UVVV))++,,,#//11&+Ah&:&:&<&<gu%% 	"!..11KK!Kq/--//dK00000r   c                    d}|                      |ddz  t                     |                      |                    d          ddz  t                     dS )zj
        L{twisted.mail.bounce.generateBounce} with big L{unicode} and
        L{bytes} messages.
        r,   s
   Test test
i'  r   z
More test
N)rA   r   r!   r   )r#   r5   s     r)   test_bounceBigMessagez!BounceTests.test_bounceBigMessage{   sW    
 	v~'=wGGGv}}W55}u7LhWWWWWr   N)r   r   )r5   r   r6   r   r7   r8   r   r   )	__name__
__module____qualname____doc__r*   r.   r4   rA   rC    r   r)   r   r      s         W W W W0W W W W0
 
 
 
>1 1 1 10X X X X X Xr   r   )
__future__r   email.messager   email.parserr   ior   r   typingr   r   r	   twisted.mailr
   twisted.trialr   TestCaser   rH   r   r)   <module>rQ      s    # " " " " "         ! ! ! ! ! !                 ' ' ' ' ' ' ' ' ' '       " " " " " "xX xX xX xX xX(# xX xX xX xX xXr   