
    :Qgu                       d Z ddlmZ ddlZddlZddlZddlZddlmZm	Z	m
Z
 ddlZddlZddlmZ ddlmZ ddlmZ ddlmZ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#m$Z$ ddl%m&Z&m'Z'm(Z(m)Z)  e$d       e d       e d       e d       e!d       e!d      gZ*d Z+d Z,d Z-d Z.d Z/d Z0d Z1d6dZ2d7dZ3d7dZ4d Z5d7dZ6d Z7ejp                  js                  d d!d"g      d8d#       Z:d$ Z;d% Z<d& Z=d9d'Z>d( Z?d9d)Z@d* ZAd+ ZBd, ZCd- ZDd. ZEd/ ZFd7d0ZGd7d1ZHd2 ZI ej                         d:d3       ZK G d4 d5      ZLy);z4Test suite for `unstructured.partition.pptx` module.    )annotationsN)AnyIteratorcast)Picture)Inches)MockFixture)FixtureRequestMockassert_round_trips_through_JSONexample_doc_pathfunction_mockproperty_mock)chunk_by_title)ElementElementMetadataImageListItemNarrativeText	PageBreakTextTitle)PptxPartitionerOptions_PptxPartitionerpartition_pptxregister_picture_partitionerzAdding a Bullet SlidetextzFind the bullet slide layoutz$Use _TextFrame.text for first bulletz5Use _TextFrame.add_paragraph() for subsequent bulletszHere is a lot of text!z Here is some text in a text box!c                     t        t        d            } | t        k(  sJ | D ]  }|j                  j                  dk(  rJ  y Nfake-power-point.pptxr   r   EXPECTED_PPTX_OUTPUTmetadatafilenameelementselements     b/var/www/html/answerous/venv/lib/python3.12/site-packages/test_unstructured/partition/test_pptx.py!test_partition_pptx_from_filenamer*   :   sN    ./FGHH++++ D((,CCCCD    c                     t        t        d      d      } | t        k(  sJ | D ]  }|j                  j                  dk(  rJ  y )Nr!   test)metadata_filenamer"   r&   s     r)   8test_partition_pptx_from_filename_with_metadata_filenamer/   A   sN    ./FG[abH++++ 3((F2223r+   c                 ,   t        t        d      d      5 } t        j                         }|j	                  | j                                t        |      }|t        k(  sJ |D ]  }|j                  j                  J  	 ddd       y# 1 sw Y   yxY w)zThe `partition_pptx() function can handle a `SpooledTemporaryFile.

    Including one that does not have its read-pointer set to the start.
    r!   rbfileN)
openr   tempfileSpooledTemporaryFilewritereadr   r#   r$   r%   )	test_filespooled_temp_filer'   r(   s       r)   %test_partition_pptx_with_spooled_filer;   H   s    
 
67	> 5)$99;	 01!'89//// 	5G##,,444	55 5 5s   A&B
=B

Bc                     t        t        d      d      5 } t        |       }d d d        t        k(  sJ t	        d |D              sJ y # 1 sw Y   )xY w)Nr!   r1   r2   c              3  L   K   | ]  }|j                   j                  d u   y wN)r$   r%   .0es     r)   	<genexpr>z0test_partition_pptx_from_file.<locals>.<genexpr>Z   s     =qqzz""d*=   "$)r4   r   r   r#   allfr'   s     r)   test_partition_pptx_from_filerG   V   sW    	67	> *!!q)*++++=H====* *s   AAc                     t        t        d      d      5 } t        | d      }d d d        t        k(  sJ |D ]  }|j                  j
                  dk(  rJ  y # 1 sw Y   7xY w)Nr!   r1   r-   )r3   r.   )r4   r   r   r#   r$   r%   )rF   r'   r(   s      r)   4test_partition_pptx_from_file_with_metadata_filenamerI   ]   sr    	67	> D!!qFCD++++ 3((F2223D Ds   AA#c                 t    t        j                  t              5  t                d d d        y # 1 sw Y   y xY wr>   )pytestraises
ValueErrorr    r+   r)   'test_partition_pptx_raises_with_neitherrO   e   s)    	z	"   s   .7c                 x    t        t        d            } | D cg c]  }|j                   c}g dk(  sJ y c c}w )Nzgroup-shapes-nested.pptx)
ABCDEFGHIJ)r   r   r   )r'   rA   s     r)   .test_partition_pptx_recurses_into_group_shapesr[   j   s4    ./IJKH$%qAFF%)[[[[%s   7c                    t        d      | d<   t        di | }t        |      j                  }t	        t
        |j                  d   j                  d         }	 |j                   y # t        $ r t        d      w xY w)Nztest-image-jpg-mime.pptx	file_pathr   z5JPEG image not recognized, needs `python-pptx>=1.0.1`rN   )r   r   r   _presentationr   r   slidesshapesimageAttributeErrorAssertionError)	opts_argsoptsprspictures       r)   ;test_it_loads_a_PPTX_with_a_JPEG_misidentified_as_image_jpgrh   o   sx    -.HIIk!.I.D
4
 
.
.C7CJJqM0034GV VTUUVs   A' 'A<c                   t        | dz        }t        j                         }|j                  d   }|j                  j                  |      }t        d      x}x}x}}|j                  j                  ||||      }	|	j                  }
d|
_
        |j                  j                  |      }t        d      x}x}x}}|j                  j                  ||||      }	|	j                  }
d|
_
        |j                  |       t        |      }|t        d      t        d      t        d      gk(  sJ |D ]  }|j                  j                   dk(  rJ  y )	Ntest-page-breaks.pptx      This is the first slide.This is the second slide.r%   r    )strpptxPresentationslide_layoutsr_   	add_slider   r`   add_textbox
text_framer   saver   r   r   r$   r%   tmp_pathr%   presentationblank_slide_layoutslidelefttopwidthheighttxBoxtfr'   r(   s                r)   $test_partition_pptx_adds_page_breaksr   ~   s^   8556H$$&L%33A6))*<=E"()+D+3+LL$$T3v>E			B(BG))*<=E"()+D+3+LL$$T3v>E			B)BGhx0H56r67   
  D((,CCCCDr+   c                   t        | dz        }t        j                         }|j                  d   }|j                  j                  |      }t        d      x}x}x}}|j                  j                  ||||      }	|	j                  }
d|
_
        |j                  j                  |      }t        d      x}x}x}}|j                  j                  ||||      }	|	j                  }
d|
_
        |j                  |       t        |d      }|t        d      t        d      gk(  sJ |D ]  }|j                  j                  dk(  rJ  y )	Nrj   rk   rl   rm   rn   F)r%   include_page_breaksr   )rq   rr   rs   rt   r_   ru   r   r`   rv   rw   r   rx   r   r   r$   r%   ry   s                r)   *test_partition_pptx_page_breaks_toggle_offr      sX   8556H$$&L%33A6))*<=E"()+D+3+LL$$T3v>E			B(BG))*<=E"()+D+3+LL$$T3v>E			B)BGhxUKH5667     D((,CCCCDr+   c                     t        t        d            } t        t        d d | D                    ddhk(  sJ | D ]  }|j                  j
                  dk(  rJ  y )Nz fake-power-point-many-pages.pptxc              3  H   K   | ]  }|j                   j                    y wr>   )r$   page_number)r@   elts     r)   rB   z1test_partition_pptx_many_pages.<locals>.<genexpr>   s     J#S\\55Js    "   rl   )r   r   setfilterr$   r%   r&   s     r)   test_partition_pptx_many_pagesr      sh    ./QRSH vdJJKLQRTUPVVVV O((,NNNNOr+   c                $   t        | dz        }t        j                         }|j                  d   }|j                  j                  |      }t        d      x}x}x}}|j                  j                  ||||      }	|	j                  }
d|
_
        t        d      x}x}x}}t        d      x}}|j                  j                  ||||      }	|	j                  }
d|
_
        t        d      x}x}x}}|j                  j                  ||||      }	|	j                  }
d|
_
        t        d      x}x}x}}|j                  j                  ||||      }	|	j                  }
d	|
_
        t        d      x}x}}t        d
      }|j                  j                  ||||      }	|	j                  }
d|
_
        |j                  |       t        |      }|t        d      t        d	      t        d      gk(  sJ |D ]  }|j                  j                   dk(  rJ  y )Nztest-ordering.pptxrk   rl   z$This is lower and should come secondr   iz)This is off the page and shouldn't appearrp   z$This is higher and should come firstg      ?z-------------TOP-------------ro   )rq   rr   rs   rt   r_   ru   r   r`   rv   rw   r   rx   r   r   r   r$   r%   ry   s                r)   #test_partition_pptx_orders_elementsr      s&   8223H$$&L%33A6))*<=E"()+D+3+LL$$T3v>E			B4BG"()+D+3+D3LL$$T3v>E			B9BG"()+D+3+LL$$T3v>E			BBG"()+D+3+LL$$T3v>E			B4BG!!9$C$%&#;DLL$$T3v>E			B-BGhx0H,-<=<=   
  A((,@@@@Ar+   c                 @   t        t        d            } | d   j                  j                  d      sJ | d   j                  j	                         j                  d      sJ | d   j                  j                  dk(  sJ | d   j                  j                  dk(  sJ y )Nfake-power-point-table.pptxr   zColumn 1Aquaz<table><tr><td>Column 1</td><td>Column 2</td><td>Column 3</td></tr><tr><td>Red</td><td>Green</td><td>Blue</td></tr><tr><td>Purple</td><td>Orange</td><td>Yellow</td></tr><tr><td>Tangerine</td><td>Pink</td><td>Aqua</td></tr></table>)	r   r   r   
startswithstripendswithr$   text_as_htmlr%   r'   s    r)    test_partition_pptx_grabs_tablesr      s    ./LMNHA;&&z222A;!!#,,V444A;,,	   A;((,IIIIr+   infer_table_structureTFc                    t        t        d      |       }t        |d   j                  d      xr |d   j                  j                  d u}|| k(  sJ y )Nr   )r   r   r   )r   r   hasattrr$   r   )r   r'   $table_element_has_text_as_html_fields      r)   )test_partition_pptx_infer_table_structurer     sa    67OdH 	$$n5 	:QK  --T9 ) 03HHHHr+   c                     t        t        d            } | d   j                  dk(  sJ | d   j                  dk(  sJ | D ]  }|j                  j                  dk(  rJ  y )Nzfake-power-point-malformed.pptxr   zProblem Date Placeholderr   z
Test Slide)r   r   r   r$   r%   r&   s     r)   test_partition_pptx_malformedr     sp    ./PQRHA;9999A;|+++ N((,MMMMNr+   c                 6    t        t        d            g k(  sJ y )Npicture.pptx)r   r   rN   r+   r)   :test_partition_pptx_generates_no_Image_elements_by_defaultr     s    *>:;rAAAr+   c                      G d d      } t        |        t        t        d            }t        |      dk(  sJ |d   }t	        |      t
        u sJ |j                  dk(  sJ y )Nc                      e Zd Zedd       Zy)Wtest_partition_pptx_uses_registered_picture_partitioner.<locals>.FakePicturePartitionerc              3     K   t        j                  |j                  j                        j	                         }t        d| d|j                          y w)NzImage with hash z, strategy: )hashlibsha1ra   blob	hexdigestr   strategy)clsrg   re   
image_hashs       r)   iter_elementszetest_partition_pptx_uses_registered_picture_partitioner.<locals>.FakePicturePartitioner.iter_elements"  sD      gmm&8&89CCEJ*:,l4==/RSSs   AAN)rg   r   re   r   returnzIterator[Element])__name__
__module____qualname__classmethodr   rN   r+   r)   FakePicturePartitionerr   !  s    		T 
	Tr+   r   r   r   r   zHImage with hash b0a1e6cf904691e6fa42bd9e72acc2b05280dc86, strategy: fast)r   r   r   lentyper   r   )r   r'   ra   s      r)   7test_partition_pptx_uses_registered_picture_partitionerr      si    T T !!78.~>?Hx=AQKE;%::ccccr+   c                    d| j                  d       t        t        d            }t        fd|D              sJ y )N2024-05-01T15:37:282unstructured.partition.pptx.get_last_modified_datereturn_valuesimple.pptxc              3  P   K   | ]  }|j                   j                  k(    y wr>   r$   last_modified)r@   rA   filesystem_last_modifieds     r)   rB   zXtest_partition_pptx_from_file_path_gets_last_modified_from_filesystem.<locals>.<genexpr>?  s!     Vqzz''+CCV   #&patchr   r   rD   )mockerr'   r   s     @r)   Etest_partition_pptx_from_file_path_gets_last_modified_from_filesystemr   7  sF    4
LL<Kc   .}=>HVXVVVVr+   c                     t        t        d      d      5 } t        |       }d d d        t        d D              sJ y # 1 sw Y   xY w)Nr   r1   r2   c              3  L   K   | ]  }|j                   j                  d u   y wr>   r   r?   s     r)   rB   zHtest_partition_pptx_from_file_gets_last_modified_None.<locals>.<genexpr>F  s     BAqzz''4/BrC   r4   r   r   rD   rE   s     r)   5test_partition_pptx_from_file_gets_last_modified_Noner   B  sI    	}-t	4 *!q)* BBBBB* *s   A  A	c                    d}d| j                  d|       t        t        d            }t        fd|D              sJ y )Nr   2020-07-05T09:24:28r   r   r   )metadata_last_modifiedc              3  P   K   | ]  }|j                   j                  k(    y wr>   r   r@   rA   r   s     r)   rB   zTtest_partition_pptx_from_file_path_prefers_metadata_last_modified.<locals>.<genexpr>T  !     Taqzz''+AATr   r   )r   r   r'   r   s      @r)   Atest_partition_pptx_from_file_path_prefers_metadata_last_modifiedr   I  sS    42
LL<Kc   '@V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   r1   )r3   r   c              3  P   K   | ]  }|j                   j                  k(    y wr>   r   r   s     r)   rB   zOtest_partition_pptx_from_file_prefers_metadata_last_modified.<locals>.<genexpr>\  r   r   r   )rF   r'   r   s     @r)   <test_partition_pptx_from_file_prefers_metadata_last_modifiedr   W  sW    2	}-t	4 Y!qAWXY T8TTTTY Ys   AAc                 j    t        t        d            } | d   j                  j                  dgk(  sJ y )Nr!   r   engr   r   r$   	languagesr   s    r)   2test_partition_pptx_element_metadata_has_languagesr   b  s3    ./FGHHA;))eW444r+   c                    t        t        d      d      } | D cg c]  }|j                  j                   }}| D ch c]2  }|j                  j                  s|j                  j                  d   4 }}d|v sJ d|v sJ y c c}w c c}w )Nzlanguage-docs/eng_spa_mult.pptxT)detect_language_per_elementr   r   spar   )r'   r(   langss      r)   8test_partition_pptx_respects_detect_language_per_elementr   g  s    :;Y]H 8@@GW''@E@ ;CawgFVFVF`F`W''*aEaE>>E>> A bs   BB	B	c                     t        j                  t              5  t        t	        d      d       d d d        y # 1 sw Y   y xY w)Nr!   r   )r   )rK   rL   	TypeErrorr   r   rN   r+   r)   :test_partition_pptx_raises_TypeError_for_invalid_languagesr   t  s8    	y	! S'(?@ERS S Ss	   :Ac                 B    t        t        d            } t        |        y r    )r   r   r   r   s    r)   test_partition_pptx_with_jsonr   |  s    ./FGHH#H-r+   c                 ~    t        d      } t        |       }t        | d      }t        |      }||k7  sJ ||k(  sJ y )Nzscience-exploration-1p.pptxro   by_title)chunking_strategy)r   r   r   )r%   r'   chunk_elementschunkss       r)   5test_add_chunking_strategy_by_title_on_partition_pptxr     sI     =>Hx0H#H
KNH%FX%%%V###r+   c                \   t        | dz        }t        j                         }|j                  j	                  |j
                  d         }|j                  j                  }|J d|_        d|j                  j                         _        |j                  |       t        |      }|d   }|d   }t        |t              sJ |j                  dk(  sJ |j                  j                   dk(  sJ t        |t              sJ |j                  dk(  sJ |j                  j                   dk(  sJ y)zPThis tests if the title attribute of a shape is correctly categorized as a titleztest-title-shape.pptxr   NLThis is a title, it's a bit long so we can make sure it's not narrative textzthis is a subtitler   )rq   rr   rs   r_   ru   rt   r`   titler   rw   add_paragraphrx   r   
isinstancer   r$   category_depth)rz   r%   rf   r}   title_shaper'   r   subtitles           r)   )test_partition_pptx_title_shape_detectionr     s)   8556H 


CJJ  !2!21!56E,,$$K"""V  3GK((*/HHX h'HQKE{H eU###

ddd>>((A--- h&&&==0000++q000r+   c                   t        | dz        }t        j                         }|j                  d   }|j                  j                  |      }|j                  }|j                  }|J d|_        |j                  d   }|j                  }d|_        |j                         }	d|	_        d|	_        |j                         }	d|	_        d|	_        |j                  d	   j                   |j                  |       t        |      }
d	t        dfd	t         dfdt         dfdt         dfg}t#        |
|      D ]  \  }}|j                  |d   k(  sJ d
|d    d|j                          t%        ||d         s0J d
|d    dt'        |      j(                   d|j                          |j*                  j,                  |d	   k(  rJ d
|d	    d|j*                  j,                   d|j                           y)zWThis tests if the level attribute of a paragraph is correctly set as the category depthztest-category-depth.pptxr   Nr   zthis is the root level bulletzthis is the level 1 bulletzthis is the level 2 bulletrl   r   z	expected z, got z for )rq   rr   rs   rt   r_   ru   r`   r   r   placeholdersrw   r   levelrx   r   r   r   zipr   r   r   r$   r   )rz   r%   rf   r|   r}   r`   r   
body_shaper   pr'   
test_casesr(   	test_cases                 r)   #test_partition_pptx_level_detectionr     s   8889H



C**1-JJ  !34E\\F,,K"""V  $$Q'J			B-BG
A)AFAG
A)AFAGJJqMHHX h'H 
Eab	
M:;	
M78	
M78	J "(J7 `||y|+[y1fW\\N-[[+aL
 	W y|nF4=+A+A*B%~V	W 

 ++y|;	`y|nF7+;+;+J+J*K5QXQ]Q]P^_	`;`r+   c                     t        t        d            } g d}t        | |      D ]R  \  }}|\  }}}|j                  j                  |k(  sJ |j                  j
                  |k(  sJ |j                  |k(  rRJ  y)zHThis tests if the hierarchy of the sample document is correctly detectedzsample-presentation.pptx))r   N b2859226ba1f9243fb3f1b2ace889f43)r   r    d13f8827e94541c8b818b0df8f942526)NN cbb95b030de22979af6bfa42969c8202)r   N e535f799d1f0e79d6777efa873a16ce1)r   r   f02bbfb417ad60daa2ba35080e96262f)r   r   414dfce72ea53cd4649176af0d62a4c1)r   r   3d45a95c79473a07db4edca5534a7c49)r   r   a33333f527851f700ca175acd04b8a2c)rl   r   6f1b87689e4da2b0fb865bc5f92d5702)r   r   3f58e0be3b8e8b15cba7adc4eae68586)NN e5de1b503e64da424fb7d8113371e16d)r   N 8319096532fe2e55f66c491ea8313150)r   r
   17a7e78277ab131a627cb4538bab7390)r   r
   41a9e1d0390f4edd77181142ceae51bc)r   r   cbbc78ef38a035fd66f7b030dcf12f66)r   r   2a551e3cbe67561debe0da262a294f24)rl   r   7a121a056eedb11ac8804d6fd17afc0c)r   r
   a24a3caf9853702cb73daae23020b7b4)r   r
   18367f334b5c8c4602ea413ab68ac35b)r   r
   7f647b1f0f20c3db40c36ab57d9a5550)r   r   591c24b41b53aba873188a0881d10961)r   r   6ec455f5f19782facf184886876c9a66)rl   r   5614b00c3f6bff23ebba1360e10f6428)r   r
   2f57a8d4182e6fd5bd5842b0a2d9841b)NN 4120066d251ba675ade42e8a167ca61f)NN efb9d74b4f8be6308c9a9006da994e12)r   N fd08cacbaddafee5cbacc02528536ee5N)r   r   r   r$   r   	parent_idid)r'   r   r(   r   expected_depthexpected_parent_idexpected_ids          r)   -test_partition_pptx_hierarchy_sample_documentr    s    ./IJKHJ> "(J7 ):C7*K...@@@))-????zz[(((	)r+   c                     dddddddS )zAll default arguments for `_XlsxPartitionerOptions`.

    Individual argument values can be changed to suit each test. Makes construction of opts more
    compact for testing purposes.
    NTFfast)r3   r]   r   include_slide_notesr   r   rN   rN   r+   r)   rd   rd     s      #$!% r+   c                     e Zd ZdZej
                  j                  dddg      	 	 	 	 dd       Zej
                  j                  dddg      	 	 	 	 dd       Zej
                  j                  dddg      	 	 	 	 dd       Z		 	 d dZ
	 	 d d	Z	 	 d d
Z	 	 	 	 d!dZ	 	 d dZej
                  j                  dddg      	 	 	 	 d"d       Zd dZ	 	 d dZ	 	 d dZ	 	 d dZ	 	 d dZ	 	 d dZej
                  j                  dddg      	 	 	 	 d#d       Z	 	 	 	 	 	 d$dZ	 	 	 	 	 	 d$dZ ej2                         d%d       Z ej2                         d%d       Z ej2                         d%d       Zy)&DescribePptxPartitionerOptionszQUnit-test suite for `unstructured.partition.xlsx.PptxPartitionerOptions` objects.	arg_valueTFc                D    ||d<   t        di |}|j                  |u sJ y )Nr   rN   )r   r   selfr%  rd   re   s       r)   Pit_knows_whether_to_emit_PageBreak_elements_as_part_of_the_output_element_streamzoDescribePptxPartitionerOptions.it_knows_whether_to_emit_PageBreak_elements_as_part_of_the_output_element_stream0  0     ,5	'(%2	2''9444r+   c                D    ||d<   t        di |}|j                  |u sJ y )Nr"  rN   )r   r"  r'  s       r)   :it_knows_whether_to_partition_content_found_in_slide_noteszYDescribePptxPartitionerOptions.it_knows_whether_to_partition_content_found_in_slide_notes9  r*  r+   c                D    ||d<   t        di |}|j                  |u sJ y )Nr   rN   )r   r   r'  s       r)   :it_knows_whether_to_include_text_as_html_in_Table_metadatazYDescribePptxPartitionerOptions.it_knows_whether_to_include_text_as_html_in_Table_metadataB  s0     .7	)*%2	2))Y666r+   c                8   t        di |}t        |j                                |j                         }t        t	        |d       t
              sJ |j                  dk(  sJ t        j                  t              5  t	        |       d d d        y # 1 sw Y   y xY w)Nrl   rN   )
r   listincrement_page_numberr   nextr   r   rK   rL   StopIterationr(  rd   re   page_break_iters       r)   Dit_generates_a_PageBreak_element_when_the_page_number_is_incrementedzcDescribePptxPartitionerOptions.it_generates_a_PageBreak_element_when_the_page_number_is_incrementedM  s     &2	2T'')*446$5yAAA1$$$]]=) 	"!	" 	" 	"s   ;BBc                    t        di |}|j                         }t        j                  t              5  t        |       d d d        |j                  dk(  sJ y # 1 sw Y   xY w)Nr   rN   )r   r1  rK   rL   r3  r2  r   r4  s       r)   @but_it_does_not_generate_a_PageBreak_element_for_the_first_slidez_DescribePptxPartitionerOptions.but_it_does_not_generate_a_PageBreak_element_for_the_first_slide[  s\     &2	2446]]=) 	"!	"1$$$	" 	"s   AA$c                
   d|d<   t        di |}t        |j                                |j                         }t        j                  t
              5  t        |       d d d        |j                  dk(  sJ y # 1 sw Y   xY w)NFr   rl   rN   )r   r0  r1  rK   rL   r3  r2  r   r4  s       r)   Sand_it_does_not_generate_a_PageBreak_element_when_include_page_breaks_option_is_offzrDescribePptxPartitionerOptions.and_it_does_not_generate_a_PageBreak_element_when_include_page_breaks_option_is_offf  sx     ,1	'(%2	2T'')*446]]=) 	"!	"1$$$	" 	"s   A99Bc                z    d|d<   d|_         t        di |}|j                  }|j                  d       |dk(  sJ y )Nza/b/spreadsheet.pptxr]   z2024-04-02T20:32:35rN   )r   r   r   assert_called_once_with)r(  rd   get_last_modified_date_re   r   s        r)   Ait_gets_last_modified_from_the_filesystem_when_a_path_is_providedz`DescribePptxPartitionerOptions.it_gets_last_modified_from_the_filesystem_when_a_path_is_providedv  sM     "8	+/D,%2	2**778NO 5555r+   c                n    t        j                  d      }||d<   t        di |}|j                  }|J y Ns   abcdefgr3   rN   )ioBytesIOr   r   )r(  rd   r3   re   r   s        r)   Mand_it_falls_back_to_None_for_the_last_modified_date_when_no_path_is_providedzlDescribePptxPartitionerOptions.and_it_falls_back_to_None_for_the_last_modified_date_when_no_path_is_provided  s@     zz*% 	&%2	2**$$$r+   r]   z
u/v/w.pptxNc                F    ||d<   t        di |}|j                  |k(  sJ y )Nr]   rN   )r   metadata_file_path)r(  r]   rd   re   s       r)   +it_uses_the_filename_argument_when_providedzJDescribePptxPartitionerOptions.it_uses_the_filename_argument_when_provided  s/     "+	+%2	2&&)333r+   c                    t        di |}|j                  dk(  sJ t        |j                                |j                  dk(  sJ t        |j                                |j                  dk(  sJ y)z)In PPTX, page-number is the slide number.r   r   rl   NrN   )r   r   r0  r1  r(  rd   re   s      r)   !it_keeps_track_of_the_page_numberz@DescribePptxPartitionerOptions.it_keeps_track_of_the_page_number  sm    %2	21$$$T'')*1$$$T'')*1$$$r+   c                $   t        di |ddi}t        |j                                |j                  d      }|j	                         }t        |t              sJ t        |t              sJ |j                  dk(  sJ |j                  dk(  sJ y )Nstarting_page_number   <table><tr/></table>r   rN   )r   r0  r1  table_metadatatext_metadatar   r   r   )r(  rd   re   rO  rP  s        r)   Eit_assigns_the_correct_page_number_when_starting_page_number_is_givenzdDescribePptxPartitionerOptions.it_assigns_the_correct_page_number_when_starting_page_number_is_given  s     &J	JJT'')*,,:P,Q**,./:::-999((A---))Q...r+   c                F    d|d<   t        di |}|j                  dk(  sJ y )Nz
l/m/n.pptxr]   rN   )r   	pptx_filerH  s      r)   Dit_uses_the_path_to_open_the_presentation_when_file_path_is_providedzcDescribePptxPartitionerOptions.it_uses_the_path_to_open_the_presentation_when_file_path_is_provided  s-     ".	+%2	2~~---r+   c                    t        j                         }|j                  d       ||d<   t        di |}|j                  }||usJ t        |t        j                        sJ |j                         dk(  sJ y r@  )	r5   r6   r7   r   rS  r   rA  rB  getvalue)r(  rd   r:   re   rS  s        r)   Fand_it_uses_a_BytesIO_file_to_replaces_a_SpooledTemporaryFile_providedzeDescribePptxPartitionerOptions.and_it_uses_a_BytesIO_file_to_replaces_a_SpooledTemporaryFile_provided  s{     %99;
+-	&%2	2NN	 1111)RZZ000!!#z111r+   c                    t        j                  d      }||d<   t        di |}|j                  }||u sJ t	        |t         j                        sJ |j                         dk(  sJ y r@  )rA  rB  r   rS  r   rV  )r(  rd   r3   re   rS  s        r)   Fand_it_uses_the_provided_file_directly_when_not_a_SpooledTemporaryFilezeDescribePptxPartitionerOptions.and_it_uses_the_provided_file_directly_when_not_a_SpooledTemporaryFile  sk     zz*% 	&%2	2NN	D   )RZZ000!!#z111r+   c                    t        di |}t        j                  t        d      5  |j                   d d d        y # 1 sw Y   y xY w)Nz1No PPTX document specified, either `filename` or )matchrN   )r   rK   rL   rM   rS  rH  s      r)   Ebut_it_raises_ValueError_when_neither_a_file_path_or_file_is_providedzdDescribePptxPartitionerOptions.but_it_raises_ValueError_when_neither_a_file_path_or_file_is_provided  s<     &2	2]]:-`a 	NN	 	 	s	   =Ar!  hi_resc                F    ||d<   t        di |}|j                  |k(  sJ y )Nr   rN   )r   r   r'  s       r)   +it_knows_which_partitioning_strategy_to_usezJDescribePptxPartitionerOptions.it_knows_which_partitioning_strategy_to_use  s-     !*	*%2	2}}	)))r+   c                8   d|_         d|_         t        di |}t        |j                                |j	                  d      }t        |t              sJ |j                  dk(  sJ |j                  dk(  sJ |j                  dk(  sJ |j                  dk(  sJ y )N
d/e/f.pptxz2024-04-02T19:51:55rM  rN  f.pptxr   rN   )r   r   r0  r1  rO  r   r   r%   r   r   r   r(  last_modified_prop_metadata_file_path_prop_rd   re   r$   s         r)   it_can_create_table_metadataz;DescribePptxPartitionerOptions.it_can_create_table_metadata  s     1= -+@(%2	2T'')*&&4J&K(O444  H,,,%%)>>>>##q((($$(>>>>r+   c                8   d|_         d|_         t        di |}t        |j                                |j	                  d      }t        |t              sJ |j                  dk(  sJ |j                  dk(  sJ |j                  dk(  sJ |j                  dk(  sJ y )Nra  z2024-04-02T19:56:40rl   )r   rb  r   rN   )r   r   r0  r1  rP  r   r   r%   r   r   r   rc  s         r)   it_can_create_text_metadataz:DescribePptxPartitionerOptions.it_can_create_text_metadata   s     1= -+@(%2	2T'')*%%Q%7(O444  H,,,%%)>>>>##q(((&&!+++r+   c                    t        |d      S )Nr   )r   r(  requests     r)   r=  z6DescribePptxPartitionerOptions.get_last_modified_date_  s    W&Z[[r+   c                $    t        |t        d      S )Nr   r   r   rj  s     r)   rd  z2DescribePptxPartitionerOptions.last_modified_prop_  s    W&<oNNr+   c                $    t        |t        d      S )NrE  rm  rj  s     r)   re  z7DescribePptxPartitionerOptions.metadata_file_path_prop_  s    W&<>RSSr+   )r%  boolrd   dict[str, Any]rd   rp  )rd   rp  r=  r   )r]   z
str | Nonerd   rp  )r%  rq   rd   rp  )rd  r   re  r   rd   rp  )rk  r
   )r   r   r   __doc__rK   markparametrizer)  r,  r.  r6  r8  r:  r>  rC  rF  rI  rQ  rT  rW  rY  r\  r_  rf  rh  fixturer=  rd  re  rN   r+   r)   r$  r$  -  sI   [[[[4-855*85 95 [[[4-855*85 95 [[[4-877*87 97"'"	%'	%%'% 
6'
6BF
6	%'	% [[[<*>?4#40>4 @4%/'/".'.2'22'2' [[[68*<=**)7* >*?#'?CG?Tb?&,#',CG,Tb,& V^^\ \ V^^O O V^^T Tr+   r$  rq  )rz   zpathlib.Path)r   ro  )r   r	   )r   rp  )Mrr  
__future__r   r   rA  pathlibr5   typingr   r   r   rr   rK   pptx.shapes.picturer   	pptx.utilr   pytest_mockr	   test_unstructured.unit_utilsr
   r   r   r   r   r   unstructured.chunking.titler   unstructured.documents.elementsr   r   r   r   r   r   r   r   unstructured.partition.pptxr   r   r   r   r#   r*   r/   r;   rG   rI   rO   r[   rh   r   r   r   r   r   rs  rt  r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  ru  rd   r$  rN   r+   r)   <module>r     s   ; "  	   & &   '  #  7	 	 	  
&'0189IJ/09: D35>3
\
	VD>D<O*AZJ  04-@I AINBd.WCUU5

S.
$1D4`n')^  0pT pTr+   