
    Ibd                         d Z ddl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 ddlmZ ddlmZ dd	lmZmZmZ d
 Z G d dej*                        Zy)zTest the bundlerextension CLI.    N)patch)TemporaryDirectory)	py3compatcheck_help_all_output)BaseJSONConfigManager   )_get_config_direnable_bundler_pythondisable_bundler_pythonc                  N    t        d       t        ddg       t        ddg       y )Nz"notebook.bundler.bundlerextensionsenabledisabler        N/usr/lib/python3/dist-packages/notebook/bundler/tests/test_bundlerextension.pytest_help_outputr      s%    >?>
K>Lr   c                   (    e Zd ZdZd Zd Zd Zd Zy)TestBundlerExtensionCLIz?Tests the bundlerextension CLI against the example zip_bundler.c                    t               }t        j                  |j                        | _        t
        j                  j                  | j                  d      | _        t
        j                  j                  | j                  d      | _	        t
        j                  j                  | j                  d      | _
        | j                  g| _        t        j                  d| j                  | j                  d      | _        | j                  j                          t        j                   t"        d| j                        | _        | j$                  j                          y)z%Build an isolated config environment.dataconfigsystem_dataz
os.environ)JUPYTER_CONFIG_DIRJUPYTER_DATA_DIRSYSTEM_JUPYTER_PATHN)r   r   cast_unicodenametest_dirospathjoindata_dir
config_dirsystem_data_dirsystem_pathr   dict	patch_envstartobjectnbextensionspatch_system_path)selftds     r   setUpzTestBundlerExtensionCLI.setUp   s    !!..rww7T]]F;'',,t}}h?!ww||DMM=I 001 L"&// $3
  	!&l!4#3#3"5$$&r   c                     t        j                  | j                  d       | j                  j	                          | j
                  j	                          y)z#Remove the test config environment.T)ignore_errorsN)shutilrmtreer   r(   stopr,   )r-   s    r   tearDownz TestBundlerExtensionCLI.tearDown0   s6    dmm48##%r   c                 "   t        d       t        j                  j                  t	        d      d      }t        |      }|j                  d      j                  di       }| j                  t        |      d       | j                  d	|       y
)z5Should add the bundler to the notebook configuration.notebook.bundler.zip_bundlerTusernbconfigr$   notebookbundlerextensions   notebook_zip_downloadN)
r   r    r!   r"   r
   r   getassertEquallenassertInr-   r$   cmbundlerss       r   test_enablez#TestBundlerExtensionCLI.test_enable6   sm    <=WW\\/t"<jI
"j966*%))*=rBX*-x8r   c                    | j                          t        d       t        j                  j	                  t        d      d      }t        |      }|j                  d      j                  di       }| j                  t        |      d       y	)
z:Should remove the bundler from the notebook configuration.r7   Tr8   r:   r;   r<   r=   r   N)
rG   r   r    r!   r"   r
   r   r@   rA   rB   rD   s       r   test_disablez$TestBundlerExtensionCLI.test_disable@   sj    =>WW\\/t"<jI
"j966*%))*=rBX*r   N)__name__
__module____qualname____doc__r/   r5   rG   rI   r   r   r   r   r      s    I'(&9+r   r   )rM   r    r2   unittestunittest.mockr   ipython_genutils.tempdirr   ipython_genutilsr   traitlets.tests.utilsr   notebook.nbextensionsr+   notebook.config_managerr   r=   r
   r   r   r   TestCaser   r   r   r   <module>rV      sG    $
 
    7 & 7 , 9 M
.+h// .+r   