B
    v9a                 @   s|   d Z ddlZddlZddlmZmZ ddlmZ ddlm	Z	 ddl
mZmZ dd ZeG d	d
 d
eZedkrxe  dS )zTest the parser and generator are inverses.

Note that this is only strictly true if we are parsing RFC valid messages and
producing RFC valid messages.
    N)policymessage_from_bytes)EmailMessage)BytesGenerator)TestEmailBaseparameterizec                sP   |   }|d  stdt|d t|d    d fdd|D S )Nr   zFirst line must contain texts   
c                s(   g | ] }t | kr | d  ndqS )N    )len).0x)stripamt $/usr/lib/python3.7/test_inversion.py
<listcomp>   s   zdedent.<locals>.<listcomp>)
splitlinesstrip
ValueErrorr	   lstripjoin)Zbstrlinesr   )r   r   dedent   s    
r   c               @   sV   e Zd ZejZeZdd ZdedfiZ	e
dde
ddd	e
dd
d	dZdd ZdS )TestInversionc             C   s<   t |tjd}t }t|}|| | | | d S )N)r   )	r   r   ZSMTPioBytesIOr   ZflattenassertEqualgetvalue)selfmsgmbgr   r   r   msg_as_input    s
    
zTestInversion.msg_as_inputZheader_with_one_space_bodysl               From: abc@xyz.com
            X-Status: 
            Subject: test

            foo
            a,  This is a test
This is a test
This is a test
This is a test
This is a test
This is a test
This is a test
This is a test
This is a test
This is a test
This is a test
This is a test
This is a test
This is a test
This is a test
This is a test
This is a test
This is a test
This is a test
This is a test
)payloada%  xy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy a
xy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy a
xy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy a
xy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy a
xy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy axy a
base64)r"   Zctezquoted-printable)Z
plain_textZbase64_textZqp_textc             K   sh   |   }d|d< d|d< d|d< |j|f| t|}t|| jd}| t|| | | | d S )NZfooZFromZbarZTozpayload round trip testZSubject)r   )Z_make_messageZset_contentbytesr   r   r   Zget_content)r   r"   kwr   r   Zmsg2r   r   r   payload_as_body9   s    zTestInversion.payload_as_bodyN)__name__
__module____qualname__r   defaultr   messager!   r   Z
msg_paramsdictZpayload_paramsr&   r   r   r   r   r      s   	

r   __main__)__doc__r   ZunittestZemailr   r   Zemail.messager   Zemail.generatorr   Ztest.test_emailr   r   r   r   r'   mainr   r   r   r   <module>   s   
*