
    :Qg?`                       d Z ddlmZ ddlZddlZddlmZ ddlmZ ddl	Z	ddl
mZmZmZmZmZ ddlmZ ddlmZmZmZmZmZmZmZ dd	lmZmZ  ed
       ed       ed       ed      gZd Zd Zd Z d Z!d Z"d Z#d Z$d Z%d Z&d Z'd Z(d Z)d Z*d Z+d Z,d Z-d Z.d  Z/d! Z0d" Z1d# Z2d$ Z3d% Z4d& Z5d' Z6d( Z7d) Z8d* Z9d+ Z:d, Z;d- Z<d. Z=d/ Z>d0 Z? G d1 d2      Z@y)3z5Test suite for `unstructured.partition.email` module.    )annotationsN)EmailMessage)Any)FixtureRequestMockassert_round_trips_through_JSONexample_doc_pathfunction_mock)chunk_by_title)CompositeElementListItemNarrativeTextTable
TableChunkTextTitle)EmailPartitioningContextpartition_emailz+This is a test email to use for unit tests.)textzImportant points:zRoses are redzViolets are bluec                 r    t        t        d            t        d      t        d      t        d      gk(  sJ y )Neml/simple-rfc-822.emlz!This is an RFC 822 email message.a\  An RFC 822 message is characterized by its simple, text-based format, which includes a header and a body. The header contains structured fields such as "From", "To", "Date", and "Subject", each followed by a colon and the corresponding information. The body follows the header, separated by a blank line, and contains the main content of the email.zThe structure ensures compatibility and readability across different email systems and clients, adhering to the standards set by the Internet Engineering Task Force (IETF).r   r	   r        c/var/www/html/answerous/venv/lib/python3.12/site-packages/test_unstructured/partition/test_email.pyAtest_partition_email_from_filename_can_partition_an_RFC_822_emailr   '   sK    +,DEF9:%	
 		
K   r   c                     t        t        d      d      5 } t        |       t        k(  sJ 	 d d d        y # 1 sw Y   y xY w)Neml/fake-email.emlrbfile)openr	   r   EXPECTED_OUTPUT)fs    r   5test_partition_email_from_file_can_partition_an_emailr%   9   s=    	34d	; :qA&/999: : :s   6?c                 6   t        j                         5 } t        t        d      d      5 }| j	                  |j                                d d d        | j                  d       t        |       t        k(  sJ 	 d d d        y # 1 sw Y   9xY w# 1 sw Y   y xY w)Nr   r   r   r    )	tempfileSpooledTemporaryFiler"   r	   writereadseekr   r#   )r!   r$   s     r   Btest_partition_email_from_spooled_temp_file_can_partition_an_emailr,   >   s    		&	&	( =D"#78$? 	!1JJqvvx 	!		!D)_<<<= =	! 	!= =s"   B B.BB	BBc                 r    t        t        d            t        d      t        d      t        d      gk(  sJ y )Nzeml/mime-html-only.emlzThis is a text/html part.zjThe first emoticon, :) , was proposed by Scott Fahlman in 1982 to indicate just or sarcasm in text emails.zGmail was launched by Google in 2004 with 1 GB of free storage, significantly more than what other services offered at the time.r   r   r   r   Ttest_partition_email_can_partition_an_HTML_only_email_with_Base64_ISO_8859_1_charsetr.   G   sK    +,DEF12'	
 	=	

K 
 
 
r   c                     t        d      } t        | d      }t        | d      }|t        k(  sJ |t        k(  sJ ||k(  sJ y )Nr   
text/plaincontent_source	text/html)r	   r   r#   )	file_pathelements_from_textelements_from_htmls      r   Ltest_extract_email_from_text_plain_matches_elements_extracted_from_text_htmlr7   U   sR     !56I(<P(;O000000!3333r   c                 B    t        t        d            } t        |        y )Nr   )r   r	   r   elementss    r   )test_partition_email_round_trips_via_jsonr;   `   s    /0DEFH#H-r   c                 >    t        t        d            t        k(  sJ y )Nzeml/fake-email-b64.emlr   r	   r#   r   r   r   Ntest_partition_email_partitions_an_HTML_part_with_Base64_encoded_UTF_8_charsetr>   h   s    +,DEF/YYYr   c                     t        t        d      d      } t        |       dk(  sJ | d   j                  j	                  d      sJ y )Nz'eml/email-no-utf8-2008-07-16.062410.emlr0   r1         u\   אני חושב שזה לא יהיה מקצועי והוגן שאני אראה לך היכן)r   r	   lenr   
startswithr9   s    r   Ztest_partition_email_partitions_a_text_plain_part_with_Base64_encoded_windows_1255_charsetrD   l   sW    BC#H
 x=BA;&&  (F  G  G  Gr   c                     t        t        d      dd      } t        |       dk(  sJ t        | d   t              sJ | d   j
                  j                  d      sJ y )Nz'eml/email-no-utf8-2014-03-17.111517.emlr3   F)r2   process_attachmentsrA   r   z4Slava Gxyzxyz Hi Slava, The password for your Google)r   r	   rB   
isinstancer   r   rC   r9   s    r   ]test_partition_email_partitions_an_html_part_with_quoted_printable_encoded_ISO_8859_1_charsetrH   v   sb    BC"!H x=Ahqk5)))A;&&']^^^r   c                 6    t        t        d            g k(  sJ y)z=Should produce no elements but should not raise an exception.zeml/empty.emlNr   r	   r   r   r   3test_partition_email_accepts_a_whitespace_only_filerK      s    +O<=CCCr   c                 :    t        t        d      d      g k(  sJ y )Neml/mime-no-body.emlFrF   rJ   r   r   r   1test_partition_email_can_partition_an_empty_emailrO      s"    ()?@V[\`bbbr   c                 :    t        t        d      d      g k(  sJ y )Nzeml/fake-encrypted.emlFrN   rJ   r   r   r   ;test_partition_email_does_not_break_on_an_encrypted_messagerQ      s"    ()ABX]^bdddr   c                     t        t        d      d      } t        |       dk(  sJ | d   }t        |t              sJ |j
                  dk(  sJ y )Nz(eml/email-inline-content-disposition.emlFrN   rA   r   zThis is a test of inline)r   r	   rB   rG   r   r   )r:   es     r   Ttest_partition_email_finds_content_when_it_is_marked_with_content_disposition_inlinerT      sX    CDZ_H x=AAa66////r   c                 D    t        t        d            } | t        k(  sJ y )Nz%eml/fake-email-malformed-encoding.eml)filenamer=   r9   s    r   5test_partition_email_from_filename_malformed_encodingrW      s!    (89`(abH&&&r   c                 x    t        j                  t        d      5  t                d d d        y # 1 sw Y   y xY w)Nz4no document specified; either a `filename` or `file`match)pytestraises
ValueErrorr   r   r   r   ?test_partition_email_raises_when_no_message_source_is_specifiedr^      s,    	z)_	`   s   09c                     t        j                  t        d      5  t        t	        d      d       d d d        y # 1 sw Y   y xY w)Nz5'application/json' is not a valid value for content_srY   r   application/jsonr1   )r[   r\   r]   r   r	   r   r   r   5test_partition_email_raises_with_invalid_content_typera      s<    	z)`	a c()=>Oabc c cs	   <Ac                    t        t        d            } t        d | D              sJ t        d | D              sJ t        d | D              sJ t        d | D              sJ t        d | D              sJ t        d | D              sJ y )Neml/mime-multi-to-cc-bcc.emlc              3  R   K   | ]  }|j                   j                  d dgk(   ! yw)John <john@example.com>Mary <mary@example.com>N)metadatabcc_recipient.0rS   s     r   	<genexpr>zZtest_partition_email_augments_message_body_elements_with_email_metadata.<locals>.<genexpr>   s.       	


  %>@Y$ZZ   %'c              3  R   K   | ]  }|j                   j                  d dgk(   ! yw)Tom <tom@example.com>Alice <alice@example.com>N)rg   cc_recipientri   s     r   rk   zZtest_partition_email_augments_message_body_elements_with_email_metadata.<locals>.<genexpr>   s.       	


$;=X#YYrl   c              3  N   K   | ]  }|j                   j                  d k(    yw)z2143658709@example.comN)rg   email_message_idri   s     r   rk   zZtest_partition_email_augments_message_body_elements_with_email_metadata.<locals>.<genexpr>   s      Y1qzz**.FFY   #%c              3  P   K   | ]  }|j                   j                  d gk(     yw)sender@example.comN)rg   	sent_fromri   s     r   rk   zZtest_partition_email_augments_message_body_elements_with_email_metadata.<locals>.<genexpr>   s#     P!qzz##(<'==P   $&c              3  R   K   | ]  }|j                   j                  d dgk(   ! yw)Bob <bob@example.com>Sue <sue@example.com>N)rg   sent_tori   s     r   rk   zZtest_partition_email_augments_message_body_elements_with_email_metadata.<locals>.<genexpr>   s+      UV

68OPPrl   c              3  N   K   | ]  }|j                   j                  d k(    yw)zExample Plain-Text MIME MessageN)rg   subjectri   s     r   rk   zZtest_partition_email_augments_message_body_elements_with_email_metadata.<locals>.<genexpr>   s      Y1qzz!!%FFYrs   r   r	   allr9   s    r   Gtest_partition_email_augments_message_body_elements_with_email_metadatar      s    /0NOPH          YPXYYYYPxPPPP Zb    YPXYYYYr   c                 |    t        t        d            } t        d | D              sJ t        d | D              sJ y )Nr   c              3  N   K   | ]  }|j                   j                  d k(    yw)zfake-email.emlNrg   rV   ri   s     r   rk   z[test_partition_email_from_filename_gets_filename_metadata_from_file_path.<locals>.<genexpr>   s      I1qzz""&66Irs   c              3  `   K   | ]&  }|j                   j                  t        d       k(   ( yw)emlN)rg   file_directoryr	   ri   s     r   rk   z[test_partition_email_from_filename_gets_filename_metadata_from_file_path.<locals>.<genexpr>   s%     Vqzz((,<U,CCVs   ,.r~   r9   s    r   Htest_partition_email_from_filename_gets_filename_metadata_from_file_pathr      s;    /0DEFHIIIIIVXVVVVr   c                     t        t        d      d      5 } t        |       }d d d        t        d D              sJ t        d |D              sJ y # 1 sw Y   2xY w)Nr   r   r    c              3  L   K   | ]  }|j                   j                  d u   y wNr   ri   s     r   rk   zMtest_partition_email_from_file_gets_filename_metadata_None.<locals>.<genexpr>   s     =qqzz""d*=   "$c              3  L   K   | ]  }|j                   j                  d u   y wr   rg   r   ri   s     r   rk   zMtest_partition_email_from_file_gets_filename_metadata_None.<locals>.<genexpr>   s     CQqzz((D0Cr   r"   r	   r   r   r$   r:   s     r   :test_partition_email_from_file_gets_filename_metadata_Noner      s^    	34d	; +q"*+ =H====C(CCCC	+ +s   AAc                     t        t        d      d      } t        d | D              sJ t        d | D              sJ y )Nr   	a/b/c.eml)metadata_filenamec              3  N   K   | ]  }|j                   j                  d k(    yw)zc.emlNr   ri   s     r   rk   zOtest_partition_email_from_filename_prefers_metadata_filename.<locals>.<genexpr>        @!qzz""g-@rs   c              3  N   K   | ]  }|j                   j                  d k(    yw)za/bNr   ri   s     r   rk   zOtest_partition_email_from_filename_prefers_metadata_filename.<locals>.<genexpr>        Daqzz((E1Drs   r~   r9   s    r   <test_partition_email_from_filename_prefers_metadata_filenamer      sA    -.+H @x@@@@D8DDDDr   c                     t        t        d      d      5 } t        | d      }d d d        t        d D              sJ t        d |D              sJ y # 1 sw Y   2xY w)Nr   r   z	d/e/f.eml)r!   r   c              3  N   K   | ]  }|j                   j                  d k(    yw)zf.emlNr   ri   s     r   rk   zKtest_partition_email_from_file_prefers_metadata_filename.<locals>.<genexpr>   r   rs   c              3  N   K   | ]  }|j                   j                  d k(    yw)zd/eNr   ri   s     r   rk   zKtest_partition_email_from_file_prefers_metadata_filename.<locals>.<genexpr>   r   rs   r   r   s     r   8test_partition_email_from_file_prefers_metadata_filenamer      sd    	34d	; Jq"[IJ @x@@@@D8DDDD	J Js   AAc                     dt        t        d            } t        fd| D              s-J d dt        | d   j                  j
                                y )Nzmessage/rfc822r   c              3  P   K   | ]  }|j                   j                  k(    y wr   )rg   filetype)rj   rS   EML_MIME_TYPEs     r   rk   zmtest_partition_email_gets_the_EML_MIME_type_in_metadata_filetype_for_message_body_elements.<locals>.<genexpr>   s      Fqzz""m3F   #&zExpected all elements to have 'z' as their filetype, but got: r   )r   r	   r   reprrg   r   )r:   r   s    @r   Ztest_partition_email_gets_the_EML_MIME_type_in_metadata_filetype_for_message_body_elementsr      s`    $M/0DEFHFXFF 
)- 9!%%../0	2Fr   c                 T    t        t        d            } t        d | D              sJ y )Nr   c              3  P   K   | ]  }|j                   j                  d gk(     yw)engNrg   	languagesri   s     r   rk   zFtest_partition_email_element_metadata_has_languages.<locals>.<genexpr>   s!     A1qzz##w.Arw   r~   r9   s    r   3test_partition_email_element_metadata_has_languagesr      s'    /0DEFHAAAAAr   c                 Z    t        t        d      dg      } t        d | D              sJ y )Nr   deu)r   c              3  P   K   | ]  }|j                   j                  d gk(     yw)r   Nr   )rj   elements     r   rk   z>test_partition_email_respects_languages_arg.<locals>.<genexpr>  s#     Mw))eW4Mrw   r~   r9   s    r   +test_partition_email_respects_languages_argr      s-    /0DERWQXYHMHMMMMr   c                     t        t        d      d      } | D ch c]2  }|j                  j                  |j                  j                  d   4 }}d|v sJ d|v sJ y c c}w )Nzlanguage-docs/eng_spa_mult.emlT)detect_language_per_elementr   r   spa)r   r	   rg   r   )r:   rS   langss      r   7test_partition_eml_respects_detect_language_per_elementr     si    9:$(H /7[!**:N:N:ZQZZ!!!$[E[E>>E>> \s
   A!A!c                 T    t        t        d            } t        d | D              sJ y )Nr   c              3  N   K   | ]  }|j                   j                  d k(    ywz2022-12-16T22:04:16+00:00Nrg   last_modifiedri   s     r   rk   zZtest_partition_email_from_file_path_gets_last_modified_from_Date_header.<locals>.<genexpr>        Y1qzz''+FFYrs   r~   r9   s    r   Gtest_partition_email_from_file_path_gets_last_modified_from_Date_headerr     s(    /0DEFHYPXYYYYr   c                     t        t        d      d      5 } t        |       }d d d        t        d D              sJ y # 1 sw Y   xY w)Nr   r   r    c              3  N   K   | ]  }|j                   j                  d k(    ywr   r   ri   s     r   rk   zUtest_partition_email_from_file_gets_last_modified_from_Date_header.<locals>.<genexpr>  r   rs   r   r   s     r   Btest_partition_email_from_file_gets_last_modified_from_Date_headerr     sK    	34d	; +q"*+ YPXYYYY+ +s   A  A	c                 b    dt        t        d            } t        fd| D              sJ y )N2020-07-05T09:24:28r   metadata_last_modifiedc              3  P   K   | ]  }|j                   j                  k(    y wr   r   rj   rS   r   s     r   rk   zUtest_partition_email_from_file_path_prefers_metadata_last_modified.<locals>.<genexpr>(  !     Taqzz''+AATr   r~   )r:   r   s    @r   Btest_partition_email_from_file_path_prefers_metadata_last_modifiedr   !  s5    2-.G]H T8TTTTr   c                     dt        t        d      d      5 } t        |       }d d d        t        fdD              sJ y # 1 sw Y    xY w)Nr   r   r   )r!   r   c              3  P   K   | ]  }|j                   j                  k(    y wr   r   r   s     r   rk   zPtest_partition_email_from_file_prefers_metadata_last_modified.<locals>.<genexpr>0  r   r   r   )r$   r:   r   s     @r   =test_partition_email_from_file_prefers_metadata_last_modifiedr   +  sX    2	34d	; Zq"BXYZ T8TTTTZ Zs   AAc                     t        t        d            } t        t        d      d      }t        |       }t        d |D              sJ || k7  sJ ||k(  sJ y)zBNote it's actually the delegate partitioners that do the chunking.zeml/fake-email.txtby_title)chunking_strategyc              3  R   K   | ]  }t        |t        t        t        f       ! y wr   )rG   r   r   r   rj   cs     r   rk   zAtest_partition_email_chunks_when_so_instructed.<locals>.<genexpr><  s     Tz!.zBCTrl   N)r   r	   r   r   )r:   chunksseparately_chunked_chunkss      r   .test_partition_email_chunks_when_so_instructedr   6  sc    /0DEFH-.BCWabF .x 8TVTTTTX....r   c                 :   t        t        d      dd      } t        |       dk(  sJ t        d | D              sJ | d   }|j                  dk(  sJ |j
                  j                  d	k(  sJ |j
                  j                  d
k(  sJ t        d | D              sJ y )Neml/fake-email-attachment.emlr   T)r   rF      c              3  <   K   | ]  }t        |t                y wr   )rG   r   r   s     r   rk   z>test_partition_email_chunks_attachments_too.<locals>.<genexpr>I  s     ?1z!-.?s   Hey this is a fake attachment!fake-attachment.txtfake-email-attachment.emlc              3  N   K   | ]  }|j                   j                  d k(    ywz2022-12-23T18:08:48+00:00Nr   r   s     r   rk   z>test_partition_email_chunks_attachments_too.<locals>.<genexpr>N  s      W1qzz''+FFWrs   )r   r	   rB   r   r   rg   rV   attached_to_filename)r   attachment_chunks     r   +test_partition_email_chunks_attachments_toor   A  s    89$ F v;!?????bz  $DDDD$$--1FFFF$$99=XXXXWPVWWWWr   c                 f    t        t        d      d      } | t        d      t        d      gk(  sJ y )Nz(eml/email-equals-attachment-filename.emlTrN   z&Below is an example of an odd filenamezOdd filename)r   r	   r   r   r9   s    r   Ctest_partition_email_also_partitions_attachments_when_so_instructedr   T  sB    CDZ^H >?n   r   c                    t        t        d      d      } | t        d      t        d      t        d      t	        d      t	        d      t	        d	      t        d
      t        d      t        d      g	k(  sJ t        d | D              sJ | d   }|j                  dk(  sJ |j                  j                  dk(  sJ |j                  j                  dk(  sJ y )Nr   TrN   zHello!zHere's the attachments!zIt includes:zLots of whitespacezLittle to no contentzand is a quick readzBest,Mallorir   c              3  N   K   | ]  }|j                   j                  d k(    ywr   r   ri   s     r   rk   z?test_partition_email_can_process_attachments.<locals>.<genexpr>o  r   rs   r   r   r   )r   r	   r   r   r   r   r   r   rg   rV   r   )r:   attachment_elements     r   ,test_partition_email_can_process_attachmentsr   _  s    89tH h/0n%%&'(&'Wi67
 
 
 
 YPXYYYY!"""&FFFF&&//3HHHH&&;;?ZZZZr   c                 R    t        t        d      d      } | t        d      gk(  sJ y )Nzeml/mime-attach-mp3.emlTrN   z(This is an email with an MP3 attachment.r   r9   s    r   Ctest_partition_email_silently_skips_attachments_it_cannot_partitionr   v  s9    23H
 @A   r   c                     e Zd ZdZd+dZd+dZd+dZd+dZd Zd Z	d Z
d	 Zd
 Zd Zd Zej                   j#                  dddg      	 	 	 	 d,d       Zd Zd Zd Zd Zd Zd Zd Zd Zd Z	 	 d-dZd Zd Zd Zd Z ej                   j#                  dd d!g      	 	 d.d"       Z!d# Z"d$ Z#d% Z$d& Z%d' Z& ejN                         d/d(       Z( ejN                         d0d)       Z)y*)1DescribeEmailPartitionerOptionszTUnit-test suite for `unstructured.partition.email.EmailPartitioningContext` objects.c                n    t        d      |d<   t        j                  di |}t        |t              sJ y )Nr   r4   r   )r	   r   loadrG   )selfctx_argsctxs      r   $it_provides_a_validating_constructorzDDescribeEmailPartitionerOptions.it_provides_a_validating_constructor  s6     01E F&++7h7#7888r   c                    t        j                  t        d      5  t        j                  di | d d d        y # 1 sw Y   y xY w)Nz1no document specified; either a `filename` or `firY   r   )r[   r\   r]   r   r   r   r   s     r   3but_it_raises_when_no_source_document_was_specifiedzSDescribeEmailPartitionerOptions.but_it_raises_when_no_source_document_was_specified  s7    ]]:-`a 	6$))5H5	6 	6 	6s	   ;Ac                    t        j                  d      |d<   t        j                  t        d      5  t        j                  di | d d d        y # 1 sw Y   y xY w)Nabcdefgr!   z)file object must be opened in binary moderY   r   )ioStringIOr[   r\   r]   r   r   r   s     r   6and_it_raises_when_a_file_open_for_reading_str_is_usedzVDescribeEmailPartitionerOptions.and_it_raises_when_a_file_open_for_reading_str_is_used  sJ    ;;y1]]:-XY 	6$))5H5	6 	6 	6s   AAc                    t        d      |d<   d|d<   t        j                  t        d      5  t	        j
                  di | d d d        y # 1 sw Y   y xY w)Nr   r4   r`   r2   z1'application/json' is not a valid value for conterY   r   )r	   r[   r\   r]   r   r   r   s     r   9and_it_raises_when_an_invalid_content_source_is_specifiedzYDescribeEmailPartitionerOptions.and_it_raises_when_an_invalid_content_source_is_specified  sR     01E F%7!"]]:-`a 	6$))5H5	6 	6 	6s   AAc                R    t        t        d            }|j                  ddgk(  sJ y )Nrc   re   rf   r   r	   bcc_addressesr   r   s     r   4it_provides_access_to_the_Bcc_addresses_when_presentzTDescribeEmailPartitionerOptions.it_provides_access_to_the_Bcc_addresses_when_present  s.    &'78V'WX  %>@Y$ZZZZr   c                H    t        t        d            }|j                  J y Nr   r   r   s     r   3but_it_returns_None_when_there_are_no_Bcc_addresseszSDescribeEmailPartitionerOptions.but_it_returns_None_when_there_are_no_Bcc_addresses  s%    &'78P'QR  (((r   c                    t        t        d            }|j                  }t        |t              sJ |j                         }t        |t              sJ |j                  d      sJ y )N!eml/mime-different-plain-html.emlz<!DOCTYPE html>r   r	   	body_partrG   r   get_contentstrrC   r   r   r  contents       r   :it_returns_the_html_body_part_when_there_is_one_by_defaultzZDescribeEmailPartitionerOptions.it_returns_the_html_body_part_when_there_is_one_by_default  s_    &'78['\]MM	)\222'')'3'''!!"3444r   c                    t        t        d      d      }|j                  }t        |t              sJ |j                         }t        |t              sJ |j                  d      sJ y )Nr  r0   r1   zThis is the text/plain part.r  r  s       r   Kbut_it_returns_the_plain_text_body_part_when_there_is_one_when_so_requestedzkDescribeEmailPartitionerOptions.but_it_returns_the_plain_text_body_part_when_there_is_one_when_so_requested  sf    &@AR^
 MM	)\222'')'3'''!!"@AAAr   c                H    t        t        d            }|j                  J y )NrM   )r   r	   r  r   s     r   .and_it_returns_None_when_the_email_has_no_bodyzNDescribeEmailPartitionerOptions.and_it_returns_None_when_the_email_has_no_body  s#    &'78N'OP}}$$$r   c                R    t        t        d            }|j                  ddgk(  sJ y )Nrc   rn   ro   r   r	   cc_addressesr   s     r   3it_provides_access_to_the_Cc_addresses_when_presentzSDescribeEmailPartitionerOptions.it_provides_access_to_the_Cc_addresses_when_present  s.    &'78V'WX$;=X#YYYYr   c                H    t        t        d            }|j                  J y r   r  r   s     r   2but_it_returns_None_when_there_are_no_Cc_addresseszRDescribeEmailPartitionerOptions.but_it_returns_None_when_there_are_no_Cc_addresses  s%    &'78P'QR'''r   )r2   expected_value)r3   htmlplain)r0   )r  r  c                >    t        |      }|j                  |k(  sJ y )Nr1   r   content_type_preference)r   r2   r  r   s       r   ?it_knows_whether_the_caller_prefers_the_HTML_or_plain_text_bodyz_DescribeEmailPartitionerOptions.it_knows_whether_the_caller_prefers_the_HTML_or_plain_text_body  s"     'nE**n<<<r   c                :    t               }|j                  dk(  sJ y )Nr  r  r   s     r   +and_it_defaults_to_preferring_the_HTML_bodyzKDescribeEmailPartitionerOptions.and_it_defaults_to_preferring_the_HTML_body  s    &(**.????r   c                N    t        t        d            }|j                  dk(  sJ y )Neml/mime-simple.emlru   )r   r	   from_addressr   s     r   &it_knows_the_From_address_of_the_emailzFDescribeEmailPartitionerOptions.it_knows_the_From_address_of_the_email  s(    &'78M'NO#7777r   c                N    t        t        d            }|j                  dk(  sJ y )Nr   z1234567890@example.comr   r	   
message_idr   s     r   1it_provides_access_to_the_Message_ID_when_presentzQDescribeEmailPartitionerOptions.it_provides_access_to_the_Message_ID_when_present  s&    &'78M'NO~~!9999r   c                H    t        t        d            }|j                  J y r   r$  r   s     r   6but_it_returns_None_when_there_is_no_Message_ID_headerzVDescribeEmailPartitionerOptions.but_it_returns_None_when_there_is_no_Message_ID_header  s#    &'78P'QR~~%%%r   c                >    t        d      }|j                  dk(  sJ y )Nr   )metadata_file_pathr   r*  r   s     r   >it_uses_the_metadata_file_path_arg_value_when_one_was_providedz^DescribeEmailPartitionerOptions.it_uses_the_metadata_file_path_arg_value_when_one_was_provided  s     &+F%%444r   c                >    t        d      }|j                  dk(  sJ y )Nz	x/y/z.emlr4   r+  r   s     r   Land_it_uses_the_file_path_arg_value_when_metadata_file_path_was_not_providedzlDescribeEmailPartitionerOptions.and_it_uses_the_file_path_arg_value_when_metadata_file_path_was_not_provided  s     &=%%444r   c                4    t               }|j                  J y r   r+  r   s     r   7and_it_returns_None_when_neither_file_path_was_providedzWDescribeEmailPartitionerOptions.and_it_returns_None_when_neither_file_path_was_provided  s    &(%%---r   c                B    d}t        |      }|j                  |k(  sJ y )Nz2023-04-08T12:18:07r   )r   r   )r   r   r   s      r   Bit_uses_the_metadata_last_modified_arg_value_when_one_was_providedzbDescribeEmailPartitionerOptions.it_uses_the_metadata_last_modified_arg_value_when_one_was_provided  s(    !6&>TU))-CCCCr   c                N    t        t        d            }|j                  dk(  sJ y )Nr   z2024-10-01T17:34:56+00:00)r   r	   r   r   s     r   Qand_it_uses_the_msg_Date_header_date_when_metadata_last_modified_was_not_providedzqDescribeEmailPartitionerOptions.and_it_uses_the_msg_Date_header_date_when_metadata_last_modified_was_not_provided  s(    &'78P'QR))-HHHHr   c                `    d}||_         t        t        d            }|j                  |k(  sJ y)zKNot an expected case as according to RFC 5322, the Date header is required.z2024-07-09T14:08:17eml/rfc822-no-date.emlN)return_valuer   r	   r   )r   get_last_modified_date_filesystem_last_modifiedr   s       r   Land_it_falls_back_to_filesystem_last_modified_when_no_Date_header_is_presentzlDescribeEmailPartitionerOptions.and_it_falls_back_to_filesystem_last_modified_when_no_Date_header_is_present  s9     $9 /G,&'78P'QR))-EEEEr   c                    t        t        d      d      5 }t        |      }|j                  J 	 d d d        y # 1 sw Y   y xY w)Nr7  r   r    )r"   r	   r   r   r   r$   r   s      r   6and_it_returns_None_when_no_last_modified_is_availablezVDescribeEmailPartitionerOptions.and_it_returns_None_when_no_last_modified_is_available  sF    "#;<dC 	6q*2C--555	6 	6 	6s	   ;Ac                f    t        t        d            }t        |j                  t              sJ y )Nr   r.  )r   r	   rG   msgr   r   s     r   Fit_loads_the_email_message_from_the_filesystem_when_a_path_is_providedzfDescribeEmailPartitionerOptions.it_loads_the_email_message_from_the_filesystem_when_a_path_is_provided"  s'    &1ABZ1[\#''<000r   c                    t        t        d      d      5 }t        |      }t        |j                  t
              sJ 	 d d d        y # 1 sw Y   y xY w)Nr   r   r    )r"   r	   r   rG   r@  r   r=  s      r   Kand_it_loads_the_email_message_from_a_file_like_object_when_one_is_providedzkDescribeEmailPartitionerOptions.and_it_loads_the_email_message_from_a_file_like_object_when_one_is_provided&  sH    "#;<dC 	5q*2Ccgg|444	5 	5 	5s   )A		Ac                H    ddd}t        |      }|j                  |k(  sJ y )Nbarqux)foobaz)kwargs)r   partitioning_kwargs)r   rI  r   s      r   6it_passes_along_the_kwargs_it_received_on_constructionzVDescribeEmailPartitionerOptions.it_passes_along_the_kwargs_it_received_on_construction-  s*    u-&f5&&&000r   rF   TFc                >    t        |      }|j                  |k(  sJ y )NrN   r   rF   )r   rF   r   s      r   ?it_knows_whether_the_caller_wants_to_also_partition_attachmentsz_DescribeEmailPartitionerOptions.it_knows_whether_the_caller_wants_to_also_partition_attachments5  s$     ';NO&&*====r   c                8    t               }|j                  du sJ y )NFrM  r   s     r   %but_by_default_it_ignores_attachmentszEDescribeEmailPartitionerOptions.but_by_default_it_ignores_attachments<  s    &(&&%///r   c                N    t        t        d            }|j                  dk(  sJ y )Nz!eml/mime-word-encoded-subject.emlu(   Simple email with ☸☿ Unicode subjectr   r	   r}   r   s     r   3it_provides_access_to_the_email_Subject_as_a_stringzSDescribeEmailPartitionerOptions.it_provides_access_to_the_email_Subject_as_a_stringB  s&    &'78['\]{{HHHHr   c                H    t        t        d            }|j                  J y )Nzeml/mime-no-subject.emlrR  r   s     r   3but_it_returns_None_when_there_is_no_Subject_headerzSDescribeEmailPartitionerOptions.but_it_returns_None_when_there_is_no_Subject_headerF  s#    &'78Q'RS{{"""r   c                R    t        t        d            }|j                  ddgk(  sJ y )Nrc   ry   rz   r   r	   to_addressesr   s     r   3it_provides_access_to_the_To_addresses_when_presentzSDescribeEmailPartitionerOptions.it_provides_access_to_the_To_addresses_when_presentL  s.    &'78V'WX$;=T#UUUUr   c                H    t        t        d            }|j                  J y )Nzeml/mime-no-to.emlrW  r   s     r   2but_it_returns_None_when_there_are_no_To_addresseszRDescribeEmailPartitionerOptions.but_it_returns_None_when_there_are_no_To_addressesP  s%    &'78L'MN'''r   c                    d d dd d di dS )Nr3   F)r4   r!   r2   r*  r   rF   rI  r   )r   s    r   r   z(DescribeEmailPartitionerOptions.ctx_argsV  s#     )"&&*#(
 	
r   c                    t        |d      S )Nz3unstructured.partition.email.get_last_modified_date)r
   )r   requests     r   r9  z7DescribeEmailPartitionerOptions.get_last_modified_date_b  s    W&[\\r   N)r   dict[str, Any])r2   r  r  ztuple[str, ...])r9  r   )rF   bool)returnr_  )r^  r   ra  r   )*__name__
__module____qualname____doc__r   r   r   r   r   r  r
  r  r  r  r  r[   markparametrizer  r  r"  r&  r(  r,  r/  r1  r3  r5  r;  r>  rA  rC  rK  rN  rP  rS  rU  rY  r[  fixturer   r9  r   r   r   r   r     s]   ^966
6[)5
B%Z( [[,,-	
=!=3B==@8:&55.D
I	F'+	F6151 [[2T5MB>#'> C>0I#V( V^^	
 	
 V^^] ]r   r   )Are  
__future__r   r   r'   email.messager   typingr   r[   test_unstructured.unit_utilsr   r   r   r	   r
   unstructured.chunking.titler   unstructured.documents.elementsr   r   r   r   r   r   r   unstructured.partition.emailr   r   r#   r   r%   r,   r.   r7   r;   r>   rD   rH   rK   rO   rQ   rT   rW   r^   ra   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   <module>rp     s4   ; " 	  &    7   S DE	"#/"$%	$:
=4.ZG	_D
0'
cZ,WDEEB
N

 Z
ZUU/X&[.
$\] \]r   