
    Mf                        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n# e$ r eZeZeZ	eZeZeZeZeZeZd
ZY nw xY wd Ze j        j        d             Z e j        d	d	          d             Ze j        defd            Ze j        defd            Ze j        de	fd            Ze j        defd            Ze j        defd            Ze j        defd            Ze j        defd            Z e j        defd            Z!e j        defd            Z"e j        defd            Z#e j        d             Z$dS )    N   )SELENIUM_GRID_DEFAULTc                       e Zd Zd ZdS )MissingDashTestingc                      t          d          )NzQdash[testing] was not installed. Please install to use the dash testing fixtures.)	Exception)selfkwargss     R/var/www/surfInsights/venv3-11/lib/python3.11/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d S |                     dd          }|                    dddd           |                    dd	d
           |                    ddt          d           |                    dd	d           |                    dddd           |                    ddd           |                    dd	d           d S )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                 n    t           sd S ddlm} t          | dd           }|| j        } ||           d S )Nr   )newhooksadd_hookspecs)r&   dash.testingr-   getattraddhooks)pluginmanagerr-   methods      r   pytest_addhooksr4   \   sW      &%%%%%]OT::F~'
F8r   )tryfirsthookwrapperc              #   d  K   d V }t           sd S |                                }|j        dk    r{|j        rvt	          | d          rh| j                                        D ]P\  }}	 |dv r|                    | j                   %# t          $ r}t          |           Y d }~Cd }~ww xY wd S d S d S d S )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       eeG 




C x6cjWT:-F-F!]0022 	 	MD'EEE))$)444   a 	 	s   %B
B'B""B'returnc               #   `   K   t                      5 } | V  ddd           dS # 1 swxY w Y   dS )z*Start a local dash server in a new thread.N)r   starters    r   dash_thread_serverrP      s~       
		 W                    #''c               #   `   K   t                      5 } | V  ddd           dS # 1 swxY w Y   dS )z=Start a Dash server with subprocess.Popen and waitress-serve.N)r   rN   s    r   dash_process_serverrS      s|       
 G                 rQ   c               #   `   K   t                      5 } | V  d d d            d S # 1 swxY w Y   d S N)r   rN   s    r   dash_multi_process_serverrV      s|      			                  rQ   c               #   `   K   t                      5 } | V  d d d            d S # 1 swxY w Y   d S rU   )r   rN   s    r   dashr_serverrX      sz      	 g                 rQ   c               #   `   K   t                      5 } | V  d d d            d S # 1 swxY w Y   d S rU   )r   rN   s    r   dashjl_serverrZ      sz      	 '                 rQ   c              #   ,  K   t          | j                            d          | j                            d          | j                            d          | j                            d          | j        j                                        |                    d          j        | j                            d          | j                            d          | j                            d          		  	        5 }|V  d d d            d S # 1 swxY w Y   d S 
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<      s4     	((55~''11>++L99))*55#88::ll:..6!.22>BB~//0ABBn&&w//

 

 

  
                 s   7D		DDc              #   .  K   t          || j                            d          | j                            d          | j                            d          | j                            d          | j        j                                        |                    d          j        | j                            d          | j                            d          | j                            d          	
  
        5 }|V  d d d            d S # 1 swxY w Y   d S r\   r   rj   rk   rl   rm   rn   ro   )rp   rP   rq   dcs       r   r=   r=      s7     	((55~''11>++L99))*55#88::ll:..6!.22>BB~//0ABBn&&w//
 
 
  
                    8D

DDc              #   .  K   t          || j                            d          | j                            d          | j                            d          | j                            d          | j        j                                        |                    d          j        | j                            d          | j                            d          | j                            d          	
  
        5 }|V  d d d            d S # 1 swxY w Y   d S r\   rs   )rp   rV   rq   rt   s       r   dash_duo_mprw      s7     	!((55~''11>++L99))*55#88::ll:..6!.22>BB~//0ABBn&&w//
 
 
  
                 ru   c              #   .  K   t          || j                            d          | j                            d          | j                            d          | j                            d          | j        j                                        |                    d          j        | j                            d          | j                            d          | j                            d          	
  
        5 }|V  d d d            d S # 1 swxY w Y   d S r\   )r   rj   rk   rl   rm   rn   ro   )rp   rX   rq   rt   s       r   r:   r:      s7     	((55~''11>++L99))*55#88::ll:..6!.22>BB~//0ABBn&&w//
 
 
  
                 ru   c              #   .  K   t          || j                            d          | j                            d          | j                            d          | j                            d          | j        j                                        |                    d          j        | j                            d          | j                            d          | j                            d          	
  
        5 }|V  d d d            d S # 1 swxY w Y   d S r\   )r   rj   rk   rl   rm   rn   ro   )rp   rZ   rq   rt   s       r   r;   r;      s7     	((55~''11>++L99))*55#88::ll:..6!.22>BB~//0ABBn&&w//
 
 
  
                 ru   c                  "    ddl m}   |             S )Nr   DiskcacheLongCallbackManager)dash.long_callbackr|   r{   s    r   diskcache_managerr~      s1          (')))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      sN    ) ) ) ) ) )
 
 
 
 
 
 
 
              -,,,,,XXXXXXXXXX JJ   'N&M+ G$K G&M'N+JJJ- - -` 
 
 
 $D111  21, N     ]     #5    
 g    
 {    
      ]      }      N      .@      * * * * *s   $> AA