ó
ù2¢\c           @   so   d  d l  m Z d  d l m Z d d l m Z d  d l Z d  d l m Z d „  Z	 d e f d	 „  ƒ  YZ
 d S(
   iÿÿÿÿ(   t   TestCase(   t   TemporaryDirectoryi   (   t   LargeFileManagerN(   t   webc         C   sA   |  j  | ƒ } y t j | ƒ Wn t k
 r< d | GHn Xd S(   s   
    Make a directory.
    s   Directory already exists: %rN(   t   _get_os_patht   ost   makedirst   OSError(   t   contents_managert   api_patht   os_path(    (    sU   lib/python2.7/site-packages/notebook/services/contents/tests/test_largefilemanager.pyt	   _make_dir   s
    t   TestLargeFileManagerc           B   s#   e  Z d  „  Z d „  Z d „  Z RS(   c         C   s4   t  ƒ  |  _ |  j j |  _ t d |  j ƒ |  _ d  S(   Nt   root_dir(   R   t	   _temp_dirt   namet   tdR   R   (   t   self(    (    sU   lib/python2.7/site-packages/notebook/services/contents/tests/test_largefilemanager.pyt   setUp   s    c         C   s   t  |  j | ƒ d S(   so   make a subdirectory at api_path

        override in subclasses if contents are not on the filesystem.
        N(   R   R   (   R   R	   (    (    sU   lib/python2.7/site-packages/notebook/services/contents/tests/test_largefilemanager.pyt   make_dir   s    c         C   s*  |  j  } | j d d ƒ } | d } | d } | j | ƒ } | j | | ƒ } t | t ƒ se t ‚ |  j d | ƒ |  j d | ƒ |  j | d | ƒ |  j | d | ƒ y3 i d d 6d d 6d d 6} | j | | d ƒ Wn, t	 j
 k
 r} |  j d t | ƒ ƒ n Xy: i d d 6d d 6d d 6d d 6} | j | | d ƒ Wn, t	 j
 k
 rw} |  j d	 t | ƒ ƒ n Xy: i d d 6d d 6d d 6d
 d 6} | j | | d ƒ Wn, t	 j
 k
 rà} |  j d t | ƒ ƒ n XyH i d d 6d d 6d d 6d
 d 6d d 6d d 6} | j | | d ƒ Wn, t	 j
 k
 rW} |  j d t | ƒ ƒ n Xi d d 6d d 6d
 d 6d d 6d d 6} | d } | d } | j | | ƒ xÁ d D]¹ } x° d D]¨ } | j | ƒ } | | d <| | d <| j | | ƒ }	 t |	 t ƒ s	t ‚ |  j d |	 ƒ |  j d |	 ƒ |  j d |	 ƒ |  j |	 d | ƒ |  j |	 d | ƒ q¹Wq¬Wd }
 |  j d ƒ | j d |
 d d ƒ } | d } | d } | j | ƒ } | j | | ƒ } t | t ƒ sÞt ‚ |  j d | ƒ |  j d | ƒ |  j | d d ƒ |  j | d d ƒ d  S(   Nt   typet   notebookR   t   patht   testi   t   chunks-   HTTP 400: Bad Request (No file type provided)sU   HTTP 400: Bad Request (File type "notebook" is not supported for large file transfer)t   files0   HTTP 400: Bad Request (No file content provided)i   u   testt   contentt   jsont   formatsR   HTTP 400: Bad Request (Must specify format of file contents as 'text' or 'base64')u   test==t   textiÿÿÿÿt   base64s   /foo/t   foos   Untitled.ipynbs   foo/Untitled.ipynb(   i   i   iÿÿÿÿ(   R   R   (   R   t   new_untitledt   gett   savet
   isinstancet   dictt   AssertionErrort   assertInt   assertEqualR   t	   HTTPErrort   strt   assertNotInR   (   R   t   cmt   modelR   R   t
   full_modelt   eR   t   fmt	   model_rest   sub_dir(    (    sU   lib/python2.7/site-packages/notebook/services/contents/tests/test_largefilemanager.pyt	   test_save!   s|    	

""	





(   t   __name__t
   __module__R   R   R2   (    (    (    sU   lib/python2.7/site-packages/notebook/services/contents/tests/test_largefilemanager.pyR      s   		(   t   unittestR    t   ipython_genutils.tempdirR   t   largefilemanagerR   R   t   tornadoR   R   R   (    (    (    sU   lib/python2.7/site-packages/notebook/services/contents/tests/test_largefilemanager.pyt   <module>   s   	