o
    i                     @   sT   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d Z	G d	d
 d
eZ
dS )    )TestCase)TemporaryDirectory   )LargeFileManagerN)webc                 C   s>   |  |}zt| W dS  ty   td| Y dS w )z
    Make a directory.
    zDirectory already exists: N)_get_os_pathosmakedirsOSErrorprint)contents_managerapi_pathos_path r   q/var/www/edux/Edux_v2/venv/lib/python3.10/site-packages/notebook/services/contents/tests/test_largefilemanager.py	_make_dir   s   
r   c                   @   s$   e Zd Zdd Zdd Zdd ZdS )TestLargeFileManagerc                 C   s$   t  | _| jj| _t| jd| _d S )N)root_dir)r   	_temp_dirnametdr   r   )selfr   r   r   setUp   s   
zTestLargeFileManager.setUpc                 C   s   t | j| dS )zomake a subdirectory at api_path

        override in subclasses if contents are not on the filesystem.
        N)r   r   )r   r   r   r   r   make_dir   s   zTestLargeFileManager.make_dirc              
   C   s4  | j }|jdd}|d }|d }||}|||}t|ts#J | d| | d| | |d | | |d | zdddd}|||d  W n tj	yj } z| dt
| W Y d }~nd }~ww zddddd	}|||d  W n tj	y } z| d
t
| W Y d }~nd }~ww zddddd	}|||d  W n tj	y } z| dt
| W Y d }~nd }~ww zddddddd}|||d  W n tj	y } z| dt
| W Y d }~nd }~ww dddddd}|d }|d }||| dD ]F}dD ]@}||}||d< ||d< |||}	t|	ts-J | d|	 | d|	 | d|	 | |	d | | |	d | qqd}
| d |j|
dd}|d }|d }||}|||}t|ts|J | d| | d| | |d d | |d d d S )Nnotebook)typer   pathtest   )r   r   chunkz-HTTP 400: Bad Request (No file type provided))r   r   r   r   zUHTTP 400: Bad Request (File type "notebook" is not supported for large file transfer)filez0HTTP 400: Bad Request (No file content provided)r   json)r   r   r   r   contentformatzRHTTP 400: Bad Request (Must specify format of file contents as 'text' or 'base64')ztest==text)r   r   r   r"   r#   )r   r   )r$   base64r   r#   z/foo/foo)r   r   zUntitled.ipynbzfoo/Untitled.ipynb)r   new_untitledgetsave
isinstancedictassertInassertEqualr   	HTTPErrorstrassertNotInr   )r   cmmodelr   r   
full_modeler   fm	model_ressub_dirr   r   r   	test_save!   s   



zTestLargeFileManager.test_saveN)__name__
__module____qualname__r   r   r9   r   r   r   r   r      s    r   )unittestr   ipython_genutils.tempdirr   largefilemanagerr   r   tornador   r   r   r   r   r   r   <module>   s    