o
    h                     @   sP   d Z ddlZddlZddlmZ ddlmZ ddlT ejj	Z
dd Zdd	 ZdS )
z4
Test the requirements functionality for processors
    N)PipelineRequirementsException)ProcessorRequirementsException)*c                 C   sJ   t | tsJ | j|d ksJ | j|d ksJ | jj|d ks#J dS )a  
    Check the values of a ProcessorRequirementsException against a dict of expected values.
    :param req_exception: the ProcessorRequirementsException to evaluate
    :param req_exception_vals: expected values for the ProcessorRequirementsException
    :return: None
    processor_typeprocessors_listrequiresN)
isinstancer   r   r   err_processorr   )req_exceptionreq_exception_vals r   b/var/www/html/env_mimamsha/lib/python3.10/site-packages/stanza/tests/pipeline/test_requirements.pycheck_exception_vals   s   r   c                  C   s  dt dddddgtg tdgdd	ddgtg tg d
dgfdt ddddg dtddgtddgdgfg} d}| D ]F\}}z
tjdi | W q@ ty } z,|d7 }t|tsaJ t|jt|kslJ t|j|D ]	\}}t	|| qrW Y d}~q@d}~ww |dksJ dS )z
    Try to build several pipelines with bad configs and check thrown exceptions against gold exceptions.
    :return: None
    zpos,depparseen)
processorsdirlangPOSProcessorposdepparsetokenize)r   r   provided_reqsr   DepparseProcessor)r   r   lemmaztokenize,mwt,lemmaT)r   r   r   	lemma_posLemmaProcessor)r   mwtr   r   r      N   r   )
TEST_MODELS_DIRsetstanzaPipeliner   r   lenprocessor_req_failszipr   )bad_config_listspipeline_fails
bad_configgold_exceptionseprocessor_req_egold_exceptionr   r   r   test_missing_requirements   s<   

r-   )__doc__pytestr!   stanza.pipeline.corer   stanza.pipeline.processorr   stanza.testsmarkpipeline
pytestmarkr   r-   r   r   r   r   <module>   s    