
    Ngu                       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 Z1d>dZ2d?dZ3d?d Z4d! Z5d?d"Z6d# Z7ej8        9                    d$d%d&g          d@d(            Z:d) Z;d* Z<d+ Z=dAd.Z>d/ Z?dAd0Z@d1 ZAd2 ZBd3 ZCd4 ZDd5 ZEd6 ZFd?d7ZGd?d8ZHd9 ZI ejJ                    dBd;            ZK G d< d=          ZLdS )Cz4Test 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    sJ d S Nfake-power-point.pptxr   r   EXPECTED_PPTX_OUTPUTmetadatafilenameelementselements     a/var/www/html/ai-engine/env/lib/python3.11/site-packages/test_unstructured/partition/test_pptx.py!test_partition_pptx_from_filenamer*   :   sc    ./FGGHHH+++++ D D(,CCCCCCD D    c                     t          t          d          d          } | t          k    sJ | D ]}|j        j        dk    sJ d S )Nr!   test)metadata_filenamer"   r&   s     r)   8test_partition_pptx_from_filename_with_metadata_filenamer/   A   sd    ./FGG[abbbH+++++ 3 3(F222223 3r+   c                 H   t          t          d          d          5 } t          j                    }|                    |                                            t          |          }|t          k    sJ |D ]}|j        j	        J 	 ddd           dS # 1 swxY w Y   dS )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7	>	> 5)$9;;	 0 0111!'8999///// 	5 	5G#,4444	55 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5s   A+BBBc                     t          t          d          d          5 } t          |           }d d d            n# 1 swxY w Y   |t          k    sJ t	          d |D                       sJ d S )Nr!   r1   r2   c              3  2   K   | ]}|j         j        d u V  d S N)r$   r%   .0es     r)   	<genexpr>z0test_partition_pptx_from_file.<locals>.<genexpr>Z   s,      ==qqz"d*======r+   )r4   r   r   r#   allfr'   s     r)   test_partition_pptx_from_filerF   V   s    	677	>	> *!!q)))* * * * * * * * * * * * * * *+++++==H==========   ;??c                     t          t          d          d          5 } t          | d          }d d d            n# 1 swxY w Y   |t          k    sJ |D ]}|j        j        dk    sJ d S )Nr!   r1   r-   )r3   r.   )r4   r   r   r#   r$   r%   )rE   r'   r(   s      r)   4test_partition_pptx_from_file_with_metadata_filenamerI   ]   s    	677	>	> D!!qFCCCD D D D D D D D D D D D D D D+++++ 3 3(F222223 3s   <A A c                     t          j        t                    5  t                       d d d            d S # 1 swxY w Y   d S r>   )pytestraises
ValueErrorr    r+   r)   'test_partition_pptx_raises_with_neitherrO   e   s    	z	"	"                   s   6::c                 f    t          t          d                    } d | D             g dk    sJ d S )Nzgroup-shapes-nested.pptxc                    g | ]	}|j         
S rN   r   r?   s     r)   
<listcomp>zBtest_partition_pptx_recurses_into_group_shapes.<locals>.<listcomp>l   s    %%%qAF%%%r+   )
ABCDEFGHIJr   r   r'   s    r)   .test_partition_pptx_recurses_into_group_shapesr_   j   sE    ./IJJKKH%%H%%%)[)[)[[[[[[[r+   	opts_argsdict[str, Any]c                
   t          d          | d<   t          di | }t          |          j        }t	          t
          |j        d         j        d                   }	 |j         d S # 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)r`   optsprspictures       r)   ;test_it_loads_a_PPTX_with_a_JPEG_misidentified_as_image_jpgrm   o   s    -.HIIIk!..I..D
4
 
 
.C7CJqM0344GV V V VTUUUVs   A( (Btmp_pathpathlib.Pathc                   t          | dz            }t          j                    }|j        d         }|j                            |          }t          d          x}x}x}}|j                            ||||          }	|	j	        }
d|
_
        |j                            |          }t          d          x}x}x}}|j                            ||||          }	|	j	        }
d|
_
        |                    |           t          |          }|t          d          t          d          t          d          gk    sJ |D ]}|j        j        dk    sJ d S )	Ntest-page-breaks.pptx      This is the first slide.This is the second slide.r%   r    )strpptxPresentationslide_layoutsre   	add_slider   rf   add_textbox
text_framer   saver   r   r   r$   r%   rn   r%   presentationblank_slide_layoutslidelefttopwidthheighttxBoxtfr'   r(   s                r)   $test_partition_pptx_adds_page_breaksr   ~   s   85566H$&&L%3A6))*<==E"())+D+3+L$$T3v>>E		B(BG))*<==E"())+D+3+L$$T3v>>E		B)BGhx000H5666r6777    
  D D(,CCCCCCD Dr+   c                   t          | dz            }t          j                    }|j        d         }|j                            |          }t          d          x}x}x}}|j                            ||||          }	|	j	        }
d|
_
        |j                            |          }t          d          x}x}x}}|j                            ||||          }	|	j	        }
d|
_
        |                    |           t          |d          }|t          d          t          d          gk    sJ |D ]}|j        j        dk    sJ d S )	Nrq   rr   rs   rt   ru   F)r%   include_page_breaksr   )rx   ry   rz   r{   re   r|   r   rf   r}   r~   r   r   r   r   r$   r%   r   s                r)   *test_partition_pptx_page_breaks_toggle_offr      s   85566H$&&L%3A6))*<==E"())+D+3+L$$T3v>>E		B(BG))*<==E"())+D+3+L$$T3v>>E		B)BGhxUKKKH56666777      D D(,CCCCCCD Dr+   c                     t          t          d                    } t          t          d d | D                                 ddhk    sJ | D ]}|j        j        dk    sJ d S )Nz fake-power-point-many-pages.pptxc              3  .   K   | ]}|j         j        V  d S r>   )r$   page_number)r@   elts     r)   rB   z1test_partition_pptx_many_pages.<locals>.<genexpr>   s'      JJ#S\5JJJJJJr+      rs   )r   r   setfilterr$   r%   r&   s     r)   test_partition_pptx_many_pagesr      s    ./QRRSSH vdJJJJJKKLLQRTUPVVVVV O O(,NNNNNNO Or+   c                6   t          | dz            }t          j                    }|j        d         }|j                            |          }t          d          x}x}x}}|j                            ||||          }	|	j	        }
d|
_
        t          d          x}x}x}}t          d          x}}|j                            ||||          }	|	j	        }
d|
_
        t          d          x}x}x}}|j                            ||||          }	|	j	        }
d|
_
        t          d          x}x}x}}|j                            ||||          }	|	j	        }
d	|
_
        t          d          x}x}}t          d
          }|j                            ||||          }	|	j	        }
d|
_
        |                    |           t          |          }|t          d          t          d	          t          d          gk    sJ |D ]}|j        j        dk    sJ d S )Nztest-ordering.pptxrr   rs   z$This is lower and should come secondr   iz)This is off the page and shouldn't appearrw   z$This is higher and should come firstg      ?z-------------TOP-------------rv   )rx   ry   rz   r{   re   r|   r   rf   r}   r~   r   r   r   r   r   r$   r%   r   s                r)   #test_partition_pptx_orders_elementsr      sP   82233H$&&L%3A6))*<==E"())+D+3+L$$T3v>>E		B4BG"())+D+3+D3L$$T3v>>E		B9BG"())+D+3+L$$T3v>>E		BBG"())+D+3+L$$T3v>>E		B4BG!!99$C$%&#;;DL$$T3v>>E		B-BGhx000H,--<==<==    
  A A(,@@@@@@A Ar+   c                 J   t          t          d                    } | d         j                            d          sJ | d         j                                                            d          sJ | d         j        j        dk    sJ | d         j        j        dk    sJ d S )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MNNHA;&&z22222A;!!##,,V44444A;,	    A;(,IIIIIIIr+   infer_table_structureTFboolc                    t          t          d          |           }t          |d         j        d          o|d         j        j        d u}|| k    sJ d S )Nr   )r   r   r   )r   r   hasattrr$   r   )r   r'   $table_element_has_text_as_html_fields      r)   )test_partition_pptx_infer_table_structurer     sq    677Od  H 	$n55 	:QK -T9 ) 03HHHHHHHr+   c                     t          t          d                    } | d         j        dk    sJ | d         j        dk    sJ | D ]}|j        j        dk    sJ d S )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     s    ./PQQRRHA;99999A;|++++ N N(,MMMMMMN Nr+   c                 J    t          t          d                    g k    sJ d S )Npicture.pptxr]   rN   r+   r)   :test_partition_pptx_generates_no_Image_elements_by_defaultr     s*    *>::;;rAAA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 d S )Nc                  &    e Zd Zed	d            ZdS )
Wtest_partition_pptx_uses_registered_picture_partitioner.<locals>.FakePicturePartitionerrl   r   rj   r   returnIterator[Element]c              3     K   t          j        |j        j                                                  }t          d| d|j                   V  d S )NzImage with hash z, strategy: )hashlibsha1rg   blob	hexdigestr   strategy)clsrl   rj   
image_hashs       r)   iter_elementszetest_partition_pptx_uses_registered_picture_partitioner.<locals>.FakePicturePartitioner.iter_elements"  sS       gm&899CCEEJR:RR4=RRSSSSSSSr+   N)rl   r   rj   r   r   r   )__name__
__module____qualname__classmethodr   rN   r+   r)   FakePicturePartitionerr   !  s8        		T 	T 	T 
	T 	T 	Tr+   r   r   r   r   zHImage with hash b0a1e6cf904691e6fa42bd9e72acc2b05280dc86, strategy: fast)r   r   r   lentyper   r   )r   r'   rg   s      r)   7test_partition_pptx_uses_registered_picture_partitionerr      s    T T T T T T T T !!7888.~>>??Hx==AQKE;;%:cccccccr+   mockerr	   c                    d|                      d           t          t          d                    }t          fd|D                       sJ d S )N2024-05-01T15:37:282unstructured.partition.pptx.get_last_modified_datereturn_valuesimple.pptxc              3  8   K   | ]}|j         j        k    V  d S 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Vqz'+CCVVVVVVr+   patchr   r   rC   )r   r'   r   s     @r)   Etest_partition_pptx_from_file_path_gets_last_modified_from_filesystemr   7  sq    4
LL<Kc     .}==>>HVVVVXVVVVVVVVVVr+   c                     t          t          d          d          5 } t          |           }d d d            n# 1 swxY w Y   t          d |D                       sJ d S )Nr   r1   r2   c              3  2   K   | ]}|j         j        d u V  d S r>   r   r?   s     r)   rB   zHtest_partition_pptx_from_file_gets_last_modified_None.<locals>.<genexpr>F  s,      BBAqz'4/BBBBBBr+   r4   r   r   rC   rD   s     r)   5test_partition_pptx_from_file_gets_last_modified_Noner   B  s    	}--t	4	4 *!q)))* * * * * * * * * * * * * * * BBBBBBBBBBBBrG   c                    d}d|                      d|           t          t          d                    }t          fd|D                       sJ d S )Nr   2020-07-05T09:24:28r   r   r   )metadata_last_modifiedc              3  8   K   | ]}|j         j        k    V  d S r>   r   r@   rA   r   s     r)   rB   zTtest_partition_pptx_from_file_path_prefers_metadata_last_modified.<locals>.<genexpr>T  .      TTaqz'+AATTTTTTr+   r   )r   r   r'   r   s      @r)   Atest_partition_pptx_from_file_path_prefers_metadata_last_modifiedr   I  s    42
LL<Kc     ''@V  H TTTT8TTTTTTTTTTr+   c                     dt          t          d          d          5 } t          |           }d d d            n# 1 swxY w Y   t          fd|D                       sJ d S )Nr   r   r1   )r3   r   c              3  8   K   | ]}|j         j        k    V  d S r>   r   r   s     r)   rB   zOtest_partition_pptx_from_file_prefers_metadata_last_modified.<locals>.<genexpr>\  r   r+   r   )rE   r'   r   s     @r)   <test_partition_pptx_from_file_prefers_metadata_last_modifiedr   W  s    2	}--t	4	4 Y!qAWXXXY Y Y Y Y Y Y Y Y Y Y Y Y Y Y TTTT8TTTTTTTTTTs   ?AAc                 p    t          t          d                    } | d         j        j        dgk    sJ d S )Nr!   r   eng)r   r   r$   	languagesr^   s    r)   2test_partition_pptx_element_metadata_has_languagesr   b  s<    ./FGGHHHA;)eW444444r+   c                     t          t          d          d          } d | D             }d | D             }d|v sJ d|v sJ d S )Nzlanguage-docs/eng_spa_mult.pptxT)detect_language_per_elementc                &    g | ]}|j         j        S rN   r$   r   r@   r(   s     r)   rR   zLtest_partition_pptx_respects_detect_language_per_element.<locals>.<listcomp>l  s    @@@GW'@@@r+   c                J    h | ] }|j         j        |j         j        d          !S )r   r   r   s     r)   	<setcomp>zKtest_partition_pptx_respects_detect_language_per_element.<locals>.<setcomp>o  s.    aaawgFVF`aW'*aaar+   r   spar]   )r'   langss     r)   8test_partition_pptx_respects_detect_language_per_elementr   g  so    :;;Y]  H A@x@@@E ba(aaaEE>>>>E>>>>>>r+   c                     t          j        t                    5  t          t	          d          d           d d d            d S # 1 swxY w Y   d S )Nr!   r   )r   )rK   rL   	TypeErrorr   r   rN   r+   r)   :test_partition_pptx_raises_TypeError_for_invalid_languagesr   t  s    	y	!	! S S'(?@@ERRRRS S S S S S S S S S S S S S S S S Ss   AA
A
c                 \    t          t          d                    } t          |            d S r    )r   r   r   r^   s    r)   test_partition_pptx_with_jsonr   |  s-    ./FGGHHH#H-----r+   c                     t          d          } t          |           }t          | d          }t          |          }||k    sJ ||k    sJ d S )Nzscience-exploration-1p.pptxrv   by_title)chunking_strategy)r   r   r   )r%   r'   chunk_elementschunkss       r)   5test_add_chunking_strategy_by_title_on_partition_pptxr     sg     =>>Hx000H#H
KKKNH%%FX%%%%V######r+   c                D   t          | dz            }t          j                    }|j                            |j        d                   }|j        j        }|J d|_        d|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 dS )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   )rx   ry   rz   re   r|   r{   rf   titler   r~   add_paragraphr   r   
isinstancer   r$   category_depth)rn   r%   rk   r   title_shaper'   r   subtitles           r)   )test_partition_pptx_title_shape_detectionr     s;   85566H 


CJ  !21!566E,$K"""V  3GK((**/HHX h''HQKE{H eU#####
ddddd>(A---- h&&&&&=00000+q000000r+   c                   t          | dz            }t          j                    }|j        d         }|j                            |          }|j        }|j        }|J d|_        |j	        d         }|j
        }d|_        |                                }	d|	_        d|	_        |                                }	d|	_        d|	_        |j        d	         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    s(J d
|d	          d|j        j         d|j                     dS )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 bulletrs   r   z	expected z, got z for )rx   ry   rz   r{   re   r|   rf   r   r   placeholdersr~   r   levelr   r   r   r   zipr   r   r   r$   r   )rn   r%   rk   r   r   rf   r   
body_shaper   pr'   
test_casesr(   	test_cases                 r)   #test_partition_pptx_level_detectionr    sD   88899H



C*1-J  !344E\F,K"""V  $Q'J		B-BG
A)AFAG
A)AFAGJqMHHX h''H 
Eab	
M:;	
M78	
M78	J "(J77 ` `|y|+++-[1-[-[W\-[-[+++aL
 
 	W 	W Wy|VV4==+AVVVV	W 	W 	W
 +y|;;;_y|__7+;+J__QXQ]__ <;;;` `r+   c                     t          t          d                    } g d}t          | |          D ]<\  }}|\  }}}|j        j        |k    sJ |j        j        |k    sJ |j        |k    sJ =dS )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)rs   r   6f1b87689e4da2b0fb865bc5f92d5702)r   r   3f58e0be3b8e8b15cba7adc4eae68586)NN e5de1b503e64da424fb7d8113371e16d)r   N 8319096532fe2e55f66c491ea8313150)r   r   17a7e78277ab131a627cb4538bab7390)r   r   41a9e1d0390f4edd77181142ceae51bc)r   r   cbbc78ef38a035fd66f7b030dcf12f66)r   r   2a551e3cbe67561debe0da262a294f24)rs   r   7a121a056eedb11ac8804d6fd17afc0c)r   r   a24a3caf9853702cb73daae23020b7b4)r   r   18367f334b5c8c4602ea413ab68ac35b)r   r   7f647b1f0f20c3db40c36ab57d9a5550)r   r   591c24b41b53aba873188a0881d10961)r   r   6ec455f5f19782facf184886876c9a66)rs   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JKKH  J> "(J77 ) ):C7*K..@@@@)-?????z[(((((	) )r+   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   rc   r   include_slide_notesr   r   rN   rN   r+   r)   r`   r`     s%     #$!%  r+   c                     e Zd ZdZej                            dddg          d*d            Zej                            dddg          d*d	            Ze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                            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                            dddg          d.d             Zd/d#Zd/d$Z ej                    d0d'            Z ej                    d0d(            Z ej                    d0d)            ZdS )1DescribePptxPartitionerOptionszQUnit-test suite for `unstructured.partition.xlsx.PptxPartitionerOptions` objects.	arg_valueTFr   r`   ra   c                >    ||d<   t          di |}|j        |u sJ d S )Nr   rN   )r   r   selfr/  r`   rj   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  <     ,5	'(%22	22'9444444r+   c                >    ||d<   t          di |}|j        |u sJ d S )Nr,  rN   )r   r,  r1  s       r)   :it_knows_whether_to_partition_content_found_in_slide_noteszYDescribePptxPartitionerOptions.it_knows_whether_to_partition_content_found_in_slide_notes9  r4  r+   c                >    ||d<   t          di |}|j        |u sJ d S )Nr   rN   )r   r   r1  s       r)   :it_knows_whether_to_include_text_as_html_in_Table_metadatazYDescribePptxPartitionerOptions.it_knows_whether_to_include_text_as_html_in_Table_metadataB  s<     .7	)*%22	22)Y666666r+   c                n   t          di |}t          |                                           |                                }t          t	          |d           t
                    sJ |j        dk    sJ t          j        t                    5  t	          |           d d d            d S # 1 swxY w Y   d S )Nrs   rN   )
r   listincrement_page_numberr   nextr   r   rK   rL   StopIterationr2  r`   rj   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	22T''))***4466$55yAAAAA1$$$$]=)) 	" 	"!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"s   B**B.1B.c                    t          di |}|                                }t          j        t                    5  t          |           d d d            n# 1 swxY w Y   |j        dk    sJ d S )Nr   rN   )r   r;  rK   rL   r=  r<  r   r>  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	224466]=)) 	" 	"!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"1$$$$$$s   AAAc                ,   d|d<   t          di |}t          |                                           |                                }t          j        t
                    5  t          |           d d d            n# 1 swxY w Y   |j        dk    sJ d S )NFr   rs   rN   )r   r:  r;  rK   rL   r=  r<  r   r>  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  s     ,1	'(%22	22T''))***4466]=)) 	" 	"!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"1$$$$$$s    A<<B B get_last_modified_date_r   c                ~    d|d<   d|_         t          di |}|j        }|                    d           |dk    sJ d S )Nza/b/spreadsheet.pptxrc   z2024-04-02T20:32:35rN   )r   r   r   assert_called_once_with)r2  r`   rE  rj   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  s_     "8	+/D,%22	22*778NOOO 5555555r+   c                f    t          j        d          }||d<   t          di |}|j        }|J d S Ns   abcdefgr3   rN   )ioBytesIOr   r   )r2  r`   r3   rj   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  sJ     z*%% 	&%22	22*$$$$$r+   rc   z
u/v/w.pptxN
str | Nonec                B    ||d<   t          di |}|j        |k    sJ d S )Nrc   rN   )r   metadata_file_path)r2  rc   r`   rj   s       r)   +it_uses_the_filename_argument_when_providedzJDescribePptxPartitionerOptions.it_uses_the_filename_argument_when_provided  s;     "+	+%22	22&)333333r+   c                    t          di |}|j        dk    sJ t          |                                           |j        dk    sJ t          |                                           |j        dk    sJ dS )z)In PPTX, page-number is the slide number.r   r   rs   NrN   )r   r   r:  r;  r2  r`   rj   s      r)   !it_keeps_track_of_the_page_numberz@DescribePptxPartitionerOptions.it_keeps_track_of_the_page_number  s    %22	221$$$$T''))***1$$$$T''))***1$$$$$$r+   c                L   t          di |ddi}t          |                                           |                    d          }|                                }t          |t                    sJ t          |t                    sJ |j        dk    sJ |j        dk    sJ d S )Nstarting_page_number   <table><tr/></table>r   rN   )r   r:  r;  table_metadatatext_metadatar   r   r   )r2  r`   rj   rZ  r[  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JJJJT''))***,,:P,QQ**,,./:::::-99999(A----)Q......r+   c                B    d|d<   t          di |}|j        dk    sJ d S )Nz
l/m/n.pptxrc   rN   )r   	pptx_filerS  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	22~------r+   c                    t          j                    }|                    d           ||d<   t          di |}|j        }||usJ t          |t          j                  sJ |                                dk    sJ d S rJ  )	r5   r6   r7   r   r^  r   rK  rL  getvalue)r2  r`   r:   rj   r^  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;;
+++-	&%22	22N	 11111)RZ00000!!##z111111r+   c                    t          j        d          }||d<   t          di |}|j        }||u sJ t	          |t           j                  sJ |                                dk    sJ d S rJ  )rK  rL  r   r^  r   ra  )r2  r`   r3   rj   r^  s        r)   Fand_it_uses_the_provided_file_directly_when_not_a_SpooledTemporaryFilezeDescribePptxPartitionerOptions.and_it_uses_the_provided_file_directly_when_not_a_SpooledTemporaryFile  s     z*%% 	&%22	22N	D    )RZ00000!!##z111111r+   c                    t          di |}t          j        t          d          5  |j         d d d            d S # 1 swxY w Y   d S )Nz1No PPTX document specified, either `filename` or )matchrN   )r   rK   rL   rM   r^  rS  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	22]:-`aaa 	 	NN	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   =AAr+  hi_resrx   c                B    ||d<   t          di |}|j        |k    sJ d S )Nr   rN   )r   r   r1  s       r)   +it_knows_which_partitioning_strategy_to_usezJDescribePptxPartitionerOptions.it_knows_which_partitioning_strategy_to_use  s:     !*	*%22	22}	))))))r+   last_modified_prop_metadata_file_path_prop_c                >   d|_         d|_         t          di |}t          |                                           |                    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 d S )N
d/e/f.pptxz2024-04-02T19:51:55rX  rY  f.pptxr   rN   )r   r   r:  r;  rZ  r   r   r%   r   r   r   r2  rk  rl  r`   rj   r$   s         r)   it_can_create_table_metadataz;DescribePptxPartitionerOptions.it_can_create_table_metadata  s     1= -+@(%22	22T''))***&&4J&KK(O44444 H,,,,%)>>>>>#q(((($(>>>>>>>r+   c                >   d|_         d|_         t          di |}t          |                                           |                    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 d S )Nrn  z2024-04-02T19:56:40rs   )r   ro  r   rN   )r   r   r:  r;  r[  r   r   r%   r   r   r   rp  s         r)   it_can_create_text_metadataz:DescribePptxPartitionerOptions.it_can_create_text_metadata   s     1= -+@(%22	22T''))***%%Q%77(O44444 H,,,,%)>>>>>#q((((&!++++++r+   requestr
   c                "    t          |d          S )Nr   )r   r2  rt  s     r)   rE  z6DescribePptxPartitionerOptions.get_last_modified_date_  s    W&Z[[[r+   c                .    t          |t          d          S )Nr   r   r   rv  s     r)   rk  z2DescribePptxPartitionerOptions.last_modified_prop_  s    W&<oNNNr+   c                .    t          |t          d          S )NrP  rx  rv  s     r)   rl  z7DescribePptxPartitionerOptions.metadata_file_path_prop_  s    W&<>RSSSr+   )r/  r   r`   ra   r`   ra   )r`   ra   rE  r   )rc   rN  r`   ra   )r/  rx   r`   ra   )rk  r   rl  r   r`   ra   )rt  r
   )r   r   r   __doc__rK   markparametrizer3  r6  r8  r@  rB  rD  rH  rM  rQ  rT  r\  r_  rb  rd  rg  rj  rq  rs  fixturerE  rk  rl  rN   r+   r)   r.  r.  -  s       [[[[4-885 5 5 985 [[4-885 5 5 985 [[4-887 7 7 987" " " "	% 	% 	% 	%% % % % 
6 
6 
6 
6	% 	% 	% 	% [[<*>??4 4 4 @?4% % % %/ / / /". . . .2 2 2 22 2 2 2    [[68*<==* * * >=*? ? ? ?&, , , ,& V^\ \ \ \ V^O O O O V^T T T T T Tr+   r.  rz  )rn   ro   )r   r   )r   r	   )r   ra   )Mr{  
__future__r   r   rK  pathlibr5   typingr   r   r   ry   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;   rF   rI   rO   r_   rm   r   r   r   r   r   r|  r}  r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r)  r~  r`   r.  rN   r+   r)   <module>r     s   ; : " " " " " "  				   & & & & & & & & & &   ' ' ' ' ' '       # # # # # #                7 6 6 6 6 6	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	            
E&'''H0111H8999HIJJJM/000M9::: D D D3 3 35 5 5> > >3 3 3  
\ \ \
	V 	V 	V 	VD D D D>D D D D<O O O*A *A *A *AZJ J J  04-@@I I I A@IN N NB B Bd d d.W W W WC C CU U U UU U U5 5 5

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