o
    ¼>h¾  ã                   @  sz   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	„ d	ejƒZdS )
é    )ÚannotationsN)ÚMessage)ÚBytesIOÚStringIO)ÚIOÚAnyStrÚCallable)Úbounce)Úunittestc                   @  sB   e Zd ZdZddd„Zddd„Zddd	„Zddd„Zddd„ZdS )ÚBounceTestsz#
    Bounce message generation
    ÚreturnÚNonec                 C  s‚   t  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Úmess© r&   ú}/var/www/vedio/testing/chatpythonscript.ninositsolution.com/env/lib/python3.10/site-packages/twisted/mail/test/test_bounce.pyÚtest_bounceMessageUnicode   ó   ÿ
ö
z%BounceTests.test_bounceMessageUnicodec                 C  s‚   t  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   r&   r&   r'   Útest_bounceMessageBytes,   r)   z#BounceTests.test_bounceMessageBytesc                 C  s®   t  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%   Úpartsr&   r&   r'   Ú"test_bounceMessageCustomTranscriptD   s*   ÿ
õ

þz.BounceTests.test_bounceMessageCustomTranscriptÚheaderr   ÚmessageÚioTypeúCallable[[AnyStr], IO[AnyStr]]c                 C  sÆ   t  ||| ƒdd¡\}}}tj ¡ }| t| d¡ƒ¡}|  |d d¡ |  |d d¡ |  |d d¡ |  	| 
¡ ¡ | ¡ }	|	d	  ¡ }
t|tƒrQ| d¡}n|}|
d
  ¡ }|  |d |¡ 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   r-   r.   r/   Ú
isinstanceÚbytes)r    r2   r3   r4   r!   r"   r#   r$   r%   r0   ÚinnerMessageÚmessageTextÚplr&   r&   r'   Ú_bounceBigMessagec   s    
ÿ

zBounceTests._bounceBigMessagec                 C  s2   d}|   |dd t¡ |   | d¡dd 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)r=   r   r   r   )r    r2   r&   r&   r'   Útest_bounceBigMessage{   s   z!BounceTests.test_bounceBigMessageN)r   r   )r2   r   r3   r   r4   r5   r   r   )	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r(   r,   r1   r=   r>   r&   r&   r&   r'   r      s    



r   )Ú
__future__r   Úemail.messager   Úemail.parserr   Úior   r   Útypingr   r   r   Útwisted.mailr	   Útwisted.trialr
   ÚTestCaser   r&   r&   r&   r'   Ú<module>   s   