ó
¬X[c           @   s˜   d  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	 m
 Z
 d d l m Z d e	 f d	 „  ƒ  YZ d
 e
 f d „  ƒ  YZ d S(   s   Test the kernels service API.iÿÿÿÿN(   t   TemporaryDirectory(   t	   py3compat(   t   LabApp(   t	   APITestert   LabTestBase(   t   assert_http_errort   BuildAPITesterc           B   s/   e  Z d  Z d Z d „  Z d „  Z d „  Z RS(   s#   Wrapper for build REST API requestss   lab/api/buildc         C   s   |  j  d d ƒ S(   Nt   GETt    (   t   _req(   t   self(    (    s>   lib/python2.7/site-packages/jupyterlab/tests/test_build_api.pyt	   getStatus   s    c         C   s   |  j  d d ƒ S(   Nt   POSTR   (   R	   (   R
   (    (    s>   lib/python2.7/site-packages/jupyterlab/tests/test_build_api.pyt   build   s    c         C   s   |  j  d d ƒ S(   Nt   DELETER   (   R	   (   R
   (    (    s>   lib/python2.7/site-packages/jupyterlab/tests/test_build_api.pyt   clear   s    (   t   __name__t
   __module__t   __doc__t   urlR   R   R   (    (    (    s>   lib/python2.7/site-packages/jupyterlab/tests/test_build_api.pyR      s
   		t   BuildAPITestc           B   sA   e  Z d  Z e Z d „  Z d „  Z d „  Z d „  Z d „  Z	 RS(   s   Test the build web service APIc         C   s)   t  ƒ  } |  j j | ƒ t j | j ƒ S(   N(   R    t   tempdirst   appendR   t   cast_unicodet   name(   R
   t   td(    (    s>   lib/python2.7/site-packages/jupyterlab/tests/test_build_api.pyt   tempdir   s    	c            s7   g  ˆ  _  ˆ  j ‡  f d †  ƒ } t ˆ  j ƒ ˆ  _ d  S(   Nc             s"   x ˆ  j  D] }  |  j ƒ  q
 Wd  S(   N(   R   t   cleanup(   t   d(   R
   (    s>   lib/python2.7/site-packages/jupyterlab/tests/test_build_api.pyt   cleanup_tempdirs'   s    (   R   t
   addCleanupR   t   requestt	   build_api(   R
   R   (    (   R
   s>   lib/python2.7/site-packages/jupyterlab/tests/test_build_api.pyt   setUp"   s    	c         C   s=   |  j  j ƒ  j ƒ  } d | k s' t ‚ d | k s9 t ‚ d S(   s3   Make sure there are no kernels running at the startt   statust   messageN(   R    R   t   jsont   AssertionError(   R
   t   resp(    (    s>   lib/python2.7/site-packages/jupyterlab/tests/test_build_api.pyt   test_get_status.   s    c         C   s(   |  j  j ƒ  } | j d k s$ t ‚ d  S(   NiÈ   (   R    R   t   status_codeR%   (   R
   R&   (    (    s>   lib/python2.7/site-packages/jupyterlab/tests/test_build_api.pyt
   test_build4   s    c            s£   t  d ƒ  ˆ  j j ƒ  Wd  QX‡  f d †  } t j d | ƒ } | j ƒ  x- ˆ  j j ƒ  j ƒ  } | d d k rN PqN qN Wˆ  j j ƒ  } | j d k sŸ t	 ‚ d  S(   Niô  c              s$   t  d ƒ  ˆ  j j ƒ  Wd  QXd  S(   Niô  (   R   R    R   (    (   R
   (    s>   lib/python2.7/site-packages/jupyterlab/tests/test_build_api.pyt   build_thread<   s    t   targetR"   t   buildingiÌ   (
   R   R    R   t	   threadingt   Threadt   startR   R$   R(   R%   (   R
   R*   t   t1R&   (    (   R
   s>   lib/python2.7/site-packages/jupyterlab/tests/test_build_api.pyt
   test_clear8   s    
(
   R   R   R   R   t   ApplicationR   R!   R'   R)   R1   (    (    (    s>   lib/python2.7/site-packages/jupyterlab/tests/test_build_api.pyR      s   				(   R   R-   t   ipython_genutils.tempdirR    t   ipython_genutilsR   t   jupyterlab.labappR   t   jupyterlab_launcher.tests.utilsR   R   t   notebook.tests.launchnotebookR   R   R   (    (    (    s>   lib/python2.7/site-packages/jupyterlab/tests/test_build_api.pyt   <module>   s   