
    $g                        d dl Z ddlmZ  G d d      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 d dlZd	Zd Ze j(                  j*                  d        Z e j.                  d	d	      d        Ze j2                  defd       Ze j2                  defd       Ze j2                  de	fd       Ze j2                  defd       Ze j2                  defd       Ze j2                  defd       Ze j2                  defd       Z e j2                  defd       Z!e j2                  defd       Z"e j2                  defd       Z#e j2                  d        Z$y# e$ r eZeZeZ	eZeZeZeZeZeZd
ZY :w xY w)    N   )SELENIUM_GRID_DEFAULTc                       e Zd Zd Zy)MissingDashTestingc                     t        d      )NzQdash[testing] was not installed. Please install to use the dash testing fixtures.)	Exception)selfkwargss     P/var/www/dash_apps/app1/venv/lib/python3.12/site-packages/dash/testing/plugin.py__init__zMissingDashTesting.__init__   s    ?
 	
    N)__name__
__module____qualname__r    r   r   r   r      s    
r   r   )ThreadedRunnerProcessRunnerRRunnerJuliaRunnerMultiProcessRunner)Browser)DashCompositeDashRCompositeDashJuliaCompositeTFc                 \   t         sy | j                  dd      }|j                  dddd       |j                  dd	d
       |j                  ddt        d       |j                  dd	d       |j                  dddd       |j                  ddd       |j                  dd	d       y )NDashzDash Integration Testsz--webdriver)ChromeFirefoxr   z"Name of the selenium driver to use)choicesdefaulthelpz--remote
store_truez$instruct pytest to use selenium grid)actionr!   z--remote-urlstorez>set a different selenium grid remote url if other than default)r#   r    r!   z
--headlessz%set this flag to run in headless modez--percy-assetsztests/assetsz3configure how Percy will discover your app's assetsz--nopercyfinalizestore_falsez3set this flag to control percy finalize at CI levelz--pausezGpause using pdb after opening the test app, so you can interact with it)
_installedgetgroup	addoptionr   )parserdashs     r   pytest_addoptionr+   ,   s    ??6#;<DNN%1	   	NN<.T   	NN%M	   	NN\0W   	NNB	   	NNB   	NNV  r   c                 d    t         sy ddlm} t        | dd       }|| j                  } ||       y )Nr   )newhooksadd_hookspecs)r&   dash.testingr-   getattraddhooks)pluginmanagerr-   methods      r   pytest_addhooksr4   \   s3     &]OT:F~''
8r   )tryfirsthookwrapperc              #   \  K   d }t         sy |j                         }|j                  dk(  r]|j                  rPt	        | d      rC| j
                  j                         D ]%  \  }}	 |dv r|j                  | j                         ' y y y y # t        $ r}t        |       Y d }~Ed }~ww xY ww)Ncallfuncargs>   dashrdashjldash_brdash_duo)r&   
get_resultwhenfailedhasattrr9   itemstake_snapshotnamer   print)itemr8   outcomereprD   fixturees          r   pytest_runtest_makereportrK   j   s      G



C xx6cjjWT:-F!]]002 	MD'EE))$))4	 .Gj
  as0   A#B,&BB,	B)B$B,$B))B,returnc               #   R   K   t               5 } |  ddd       y# 1 sw Y   yxY ww)z*Start a local dash server in a new thread.N)r   starters    r   dash_thread_serverrP      s)      
	 W     '	'$'c               #   R   K   t               5 } |  ddd       y# 1 sw Y   yxY ww)z=Start a Dash server with subprocess.Popen and waitress-serve.N)r   rN   s    r   dash_process_serverrS      s(      
 G  rQ   c               #   R   K   t               5 } |  d d d        y # 1 sw Y   y xY wwN)r   rN   s    r   dash_multi_process_serverrV      s'     		   rQ   c               #   R   K   t               5 } |  d d d        y # 1 sw Y   y xY wwrU   )r   rN   s    r   dashr_serverrX      s&     	 g  rQ   c               #   R   K   t               5 } |  d d d        y # 1 sw Y   y xY wwrU   )r   rN   s    r   dashjl_serverrZ      s&     	 '  rQ   c              #   :  K   t        | j                  j                  d      | j                  j                  d      | j                  j                  d      | j                  j                  d      | j                  j                  j	                         |j                  d      j                  | j                  j                  d      | j                  j                  d      | j                  j                  d      		      5 }| d d d        y # 1 sw Y   y xY ww
N	webdriverremote
remote_urlheadlessdownloadpercy_assetsnopercyfinalizepause)	browserr^   r_   r`   optionsdownload_pathpercy_assets_rootpercy_finalizerd   )r   config	getoptionhookpytest_setup_optionsmkdirstrpath)requesttmpdirre   s      r   r<   r<      s     	((5~~''1>>++L9))*5##88:ll:.66!..22>B~~//0ABnn&&w/

  
  s   C?DD	DDDc              #   <  K   t        || j                  j                  d      | j                  j                  d      | j                  j                  d      | j                  j                  d      | j                  j                  j	                         |j                  d      j                  | j                  j                  d      | j                  j                  d      | j                  j                  d      	
      5 }| d d d        y # 1 sw Y   y xY wwr\   r   rj   rk   rl   rm   rn   ro   )rp   rP   rq   dcs       r   r=   r=      s     	((5~~''1>>++L9))*5##88:ll:.66!..22>B~~//0ABnn&&w/
  
     D DD	DDDc              #   <  K   t        || j                  j                  d      | j                  j                  d      | j                  j                  d      | j                  j                  d      | j                  j                  j	                         |j                  d      j                  | j                  j                  d      | j                  j                  d      | j                  j                  d      	
      5 }| d d d        y # 1 sw Y   y xY wwr\   rs   )rp   rV   rq   rt   s       r   dash_duo_mprw      s     	!((5~~''1>>++L9))*5##88:ll:.66!..22>B~~//0ABnn&&w/
  
  ru   c              #   <  K   t        || j                  j                  d      | j                  j                  d      | j                  j                  d      | j                  j                  d      | j                  j                  j	                         |j                  d      j                  | j                  j                  d      | j                  j                  d      | j                  j                  d      	
      5 }| d d d        y # 1 sw Y   y xY wwr\   )r   rj   rk   rl   rm   rn   ro   )rp   rX   rq   rt   s       r   r:   r:      s     	((5~~''1>>++L9))*5##88:ll:.66!..22>B~~//0ABnn&&w/
  
  ru   c              #   <  K   t        || j                  j                  d      | j                  j                  d      | j                  j                  d      | j                  j                  d      | j                  j                  j	                         |j                  d      j                  | j                  j                  d      | j                  j                  d      | j                  j                  d      	
      5 }| d d d        y # 1 sw Y   y xY wwr\   )r   rj   rk   rl   rm   rn   ro   )rp   rZ   rq   rt   s       r   r;   r;      s     	((5~~''1>>++L9))*5##88:ll:.66!..22>B~~//0ABnn&&w/
  
  ru   c                      ddl m}   |        S )Nr   DiskcacheLongCallbackManager)dash.long_callbackr|   r{   s    r   diskcache_managerr~      s     ())r   )%pytestconstsr   r    dash.testing.application_runnersr   r   r   r   r   dash.testing.browserr   dash.testing.compositer   r   r   dash_testing_stubr&   ImportErrorr+   markr5   r4   hookimplrK   rI   rP   rS   rV   rX   rZ   r<   r=   rw   r:   r;   r~   r   r   r   <module>r      s    )
 
  -XX J-` 
 
 $D1 2, N   ]   #5  
 g  
 {  
    ]    }    N    .@    * *q  'N&M+ G$K G&M'N+Js   $E E54E5