o
    i                     @   sX   d 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 G dd	 d	eZdS )
zTest yarn registry replacement    N)join)patch)commands   )AppHandlerTestc                   @   s4   e Zd Zdd Zdd Zdd Zdd Zd	d
 ZdS )TestAppHandlerRegistryc                 C   sh   t d&}td|_td}t|}|d | |i i d W d    d S 1 s-w   Y  d S )Nzjupyterlab.commands.whichzCommand not found
jupyterlabnodezyarn configz
npm config)	r   
ValueErrorside_effectlogging	getLoggerr   _yarn_configassert_called_once_withassertDictEqual)selfwhichloggerconfig r   Y/var/www/edux/Edux_v2/venv/lib/python3.10/site-packages/jupyterlab/tests/test_registry.pytest_node_not_available   s   




"z.TestAppHandlerRegistry.test_node_not_availablec              
   C   s   t d:}d}dddt|d d ddt|d d g|_td	}t|}| |d
|id
|id W d    d S 1 sAw   Y  d S )Nsubprocess.check_outputhttps://private.yarn/manager   
$   {"type":"info","data":"yarn config"}&   {"type":"inspect","data":{"registry":"utf-8   "}}#   {"type":"info","data":"npm config"}r   registryr
   )	r   r   bytesreturn_valuer   r   r   r   r   )r   check_outputyarn_registryr   r   r   r   r   test_yarn_config   s4   


"z'TestAppHandlerRegistry.test_yarn_configc                 C   sl   t d(}tjdg dddd|_td}t|}| |i i d W d    d S 1 s/w   Y  d S )	Nr   r   )yarnr   list    s   yarn config failed.)stderrr   r
   )	r   
subprocessCalledProcessErrorr   r   r   r   r   r   )r   r$   r   r   r   r   r   test_yarn_config_failure7   s   


"z/TestAppHandlerRegistry.test_yarn_config_failurec              
   C   sx   t d.}d}dddt|d d ddt|d d g|_t }| |j| W d    d S 1 s5w   Y  d S )	Nr   r   r   r   r   r   r   r    )r   r   r"   r#   r   
AppOptionsassertEqualr!   )r   r$   r%   handlerr   r   r   test_get_registryB   s(   
"z(TestAppHandlerRegistry.test_get_registryc              
   C   s   t d^}d}dddt|d d ddt|d d g|_t| jd	}tt }|	  t|d
}t
|}| }W d    n1 sHw   Y  | tj| | || W d    d S 1 sew   Y  d S )Nr   r   r   r   r   r   r   r    stagingz	yarn.lock)r   r   r"   r#   pjoinapp_dirr   _AppHandlerr.   _populate_stagingopenreadassertNotInYARN_DEFAULT_REGISTRY)r   r$   r%   r2   r0   	lock_pathflockr   r   r   test_populate_stagingV   s6   



"z,TestAppHandlerRegistry.test_populate_stagingN)__name__
__module____qualname__r   r&   r-   r1   r>   r   r   r   r   r      s    r   )__doc__r   r+   os.pathr   r3   unittest.mockr   r   r   test_jupyterlabr   r   r   r   r   r   <module>   s    