a  ze@s|dZddlZddlZddlmZmZddlmZddlm Z ddl m Z m Z ddZ e Gd d d e Zed krxedS) 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)policymessage_from_bytes) EmailMessage)BytesGenerator) TestEmailBase parameterizecsP|}|dstdt|dt|ddfdd|DS)NrzFirst line must contain texts cs(g|] }t|kr |dndqS)N)len).0xZstripamtR/opt/bitninja-python-dojo/embedded/lib/python3.9/test/test_email/test_inversion.py szdedent..) splitlinesstrip ValueErrorr lstripjoin)Zbstrlinesr r rdedents  rc@sVeZdZejZeZddZdedfiZ e dde ddd e dd d d Z d d Z dS) TestInversioncCs<t|tjd}t}t|}|||||dS)Nr) rrZSMTPioBytesIOrZflatten assertEqualgetvalue)selfmsgmbgr r r msg_as_input s  zTestInversion.msg_as_inputZheader_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#Zctezquoted-printable)Z plain_textZ base64_textZqp_textcKsl|}d|d<d|d<d|d<|j|fi|t|}t||jd}|t|||||dS)NZfooZFromZbarZTozpayload round trip testZSubjectr)Z _make_messageZ set_contentbytesrrrZ get_content)rr#kwrr Zmsg2r r rpayload_as_body9szTestInversion.payload_as_bodyN) __name__ __module__ __qualname__rdefaultrmessager"rZ msg_paramsdictZpayload_paramsr'r r r rrs    r__main__)__doc__rZunittestZemailrrZ email.messagerZemail.generatorrZtest.test_emailrrrrr(mainr r r rs   *