
    oi                     ^    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	e      Zy)
zTest yarn registry replacement    N)join)patch)commands   )AppHandlerTestc                   *    e Zd Zd Zd Zd Zd Zd Zy)TestAppHandlerRegistryc                    t        d      5 }t        d      |_        t        j                  d      }t        j                  |      }|j                  d       | j                  |i i d       d d d        y # 1 sw Y   y xY w)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configs       f/home/ubuntu/docker-apps/notebooks/venv/lib/python3.12/site-packages/jupyterlab/tests/test_registry.pytest_node_not_availablez.TestAppHandlerRegistry.test_node_not_available   sy     ./ 	P5 *+> ?E&&|4F**62F))&1  2)NO	P 	P 	Ps   A!A66A?c                 B   t        d      5 }d}dj                  ddt        |d      z   dz   ddt        |d      z   dz   g      |_        t	        j
                  d	      }t        j                  |      }| j                  |d
|id
|id       d d d        y # 1 sw Y   y xY w)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   s        r   test_yarn_configz'TestAppHandlerRegistry.test_yarn_config   s    ,- 	:M(-

;=M734 ;=M734	)L% &&|4F**62F  $.#>#-}"=#	 	 	s   B BBc                    t        d      5 }t        j                  dg ddd      |_        t	        j
                  d      }t        j                  |      }| j                  |i i d       d d d        y # 1 sw Y   y xY w)	Nr   r   )yarnr   list    s   yarn config failed.)stderrr   r   )	r   
subprocessCalledProcessErrorr   r   r   r   r   r   )r   r'   r   r   s       r   test_yarn_config_failurez/TestAppHandlerRegistry.test_yarn_config_failure7   s{    ,- 	P'1'D'D-s;Q(L$ &&|4F**62F  2)NO	P 	P 	Ps   A A55A>c                    t        d      5 }d}dj                  ddt        |d      z   dz   ddt        |d      z   dz   g      |_        t	        j
                         }| j                  |j                  |       d d d        y # 1 sw Y   y xY w)	Nr   r   r   r   r    r!   r"   r#   )r   r   r%   r&   r   
AppOptionsassertEqualr$   )r   r'   r(   handlers       r   test_get_registryz(TestAppHandlerRegistry.test_get_registryB   s    ,- 	>:M(-

;=M734 ;=M734	)L% ))+GW--}=#	> 	> 	>s   A-BBc                 2   t        d      5 }d}dj                  ddt        |d      z   dz   ddt        |d      z   dz   g      |_        t	        | j
                  d	      }t        j                  t        j                               }|j                          t	        |d
      }t        |      5 }|j                         }d d d        | j                  t        j                         | j                  ||       d d d        y # 1 sw Y   DxY w# 1 sw Y   y xY w)Nr   r   r   r   r    r!   r"   r#   stagingz	yarn.lock)r   r   r%   r&   pjoinapp_dirr   _AppHandlerr3   _populate_stagingopenreadassertNotInYARN_DEFAULT_REGISTRY)r   r'   r(   r8   r5   	lock_pathflocks           r   test_populate_stagingz,TestAppHandlerRegistry.test_populate_stagingV   s   ,- 	2:M(-

;=M734 ;=M734	)L% DLL)4G**8+>+>+@AG%%'g{3Ii  Avvx  X;;TB]D13	2 	2(   )	2 	2s$   B!D-D>:DD
	DDN)__name__
__module____qualname__r   r)   r1   r6   rD    r-   r   r	   r	      s    
P4	P>(2r-   r	   )__doc__r   r/   os.pathr   r9   unittest.mockr   r   r   test_jupyterlabr   r	   rH   r-   r   <module>rM      s*    $
   !   +`2^ `2r-   