ó
ù2¢\c           @   só   d  Z  d d l Z d d l Z d d l Z y d d l m Z Wn! e k
 ra d d l m Z n Xd d l m	 Z	 d d l
 m Z d d l m Z d d l j Z d d l m Z d d	 l m Z m Z m Z d
 „  Z d e j f d „  ƒ  YZ d S(   s   Test the bundlerextension CLI.iÿÿÿÿN(   t   patch(   t   TemporaryDirectory(   t	   py3compat(   t   check_help_all_output(   t   BaseJSONConfigManageri   (   t   _get_config_dirt   enable_bundler_pythont   disable_bundler_pythonc           C   s.   t  d ƒ t  d d g ƒ t  d d g ƒ d  S(   Ns"   notebook.bundler.bundlerextensionst   enablet   disable(   R   (    (    (    sK   lib/python2.7/site-packages/notebook/bundler/tests/test_bundlerextension.pyt   test_help_output   s    
t   TestBundlerExtensionCLIc           B   s2   e  Z d  Z d „  Z d „  Z d „  Z d „  Z RS(   s?   Tests the bundlerextension CLI against the example zip_bundler.c         C   sà   t  ƒ  } t j | j ƒ |  _ t j j |  j d ƒ |  _ t j j |  j d ƒ |  _	 t j j |  j d ƒ |  _
 |  j
 g |  _ t j d i |  j	 d 6|  j d 6ƒ |  _ |  j j ƒ  t j t d |  j ƒ |  _ |  j j ƒ  d S(	   s%   Build an isolated config environment.t   datat   configt   system_datas
   os.environt   JUPYTER_CONFIG_DIRt   JUPYTER_DATA_DIRt   SYSTEM_JUPYTER_PATHN(   R   R   t   cast_unicodet   namet   test_dirt   ost   patht   joint   data_dirt
   config_dirt   system_data_dirt   system_pathR    t   dictt	   patch_envt   startt   objectt   nbextensionst   patch_system_path(   t   selft   td(    (    sK   lib/python2.7/site-packages/notebook/bundler/tests/test_bundlerextension.pyt   setUp    s    	
	c         C   s4   t  j |  j d t ƒ|  j j ƒ  |  j j ƒ  d S(   s#   Remove the test config environment.t   ignore_errorsN(   t   shutilt   rmtreeR   t   TrueR   t   stopR!   (   R"   (    (    sK   lib/python2.7/site-packages/notebook/bundler/tests/test_bundlerextension.pyt   tearDown4   s    c         C   s|   t  d ƒ t j j t d t ƒ d ƒ } t d | ƒ } | j d ƒ j d i  ƒ } |  j t	 | ƒ d ƒ |  j
 d | ƒ d	 S(
   s5   Should add the bundler to the notebook configuration.s   notebook.bundler.zip_bundlert   usert   nbconfigR   t   notebookt   bundlerextensionsi   t   notebook_zip_downloadN(   R   R   R   R   R   R(   R   t   gett   assertEqualt   lent   assertIn(   R"   R   t   cmt   bundlers(    (    sK   lib/python2.7/site-packages/notebook/bundler/tests/test_bundlerextension.pyt   test_enable:   s    
c         C   sv   |  j  ƒ  t d ƒ t j j t d t ƒ d ƒ } t d | ƒ } | j d ƒ j d i  ƒ } |  j	 t
 | ƒ d ƒ d S(	   s:   Should remove the bundler from the notebook configuration.s   notebook.bundler.zip_bundlerR+   R,   R   R-   R.   i    N(   R6   R   R   R   R   R   R(   R   R0   R1   R2   (   R"   R   R4   R5   (    (    sK   lib/python2.7/site-packages/notebook/bundler/tests/test_bundlerextension.pyt   test_disableD   s    

(   t   __name__t
   __module__t   __doc__R$   R*   R6   R7   (    (    (    sK   lib/python2.7/site-packages/notebook/bundler/tests/test_bundlerextension.pyR      s
   			
(   R:   R   R&   t   unittestt   unittest.mockR    t   ImportErrort   mockt   ipython_genutils.tempdirR   t   ipython_genutilsR   t   traitlets.tests.utilsR   t   notebook.nbextensionsR    t   notebook.config_managerR   R.   R   R   R   R
   t   TestCaseR   (    (    (    sK   lib/python2.7/site-packages/notebook/bundler/tests/test_bundlerextension.pyt   <module>   s   	