U
    Pe                     @   s   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mZ ejdd Zd	Zd
d Zdd Zdd Zdd Zdd ZdS )z/
Resource loading tests
======================
    N)patch)Cache)Clock)resource_findresource_add_pathc                   C   s   dS )Nzuix/textinput.py r   r   r   =/tmp/pip-unpacked-wheel-xzebddm3/kivy/tests/test_resources.py	test_file   s    r	   zkv.resourcefindc                 C   s:   t t t| }|d k	stt t| }||ks6td S )Nr   removeRESOURCE_CACHEr   AssertionErrorgetr	   
found_filecached_filenamer   r   r   test_load_resource_cached   s
    
r   c                 C   s>   t t t| dd}|d k	s"tt t| }|d ks:td S )NF)Z	use_cacher
   r   r   r   r   test_load_resource_not_cached   s
    
r   c               
   C   s   t t d} t| }|d ks"tt }tj	|| }t
|d W 5 Q R X t| }|d ksdtt t| }|d ks|tt| t| }||kst|t t| kstW 5 Q R X d S )Nzmissing_test_file.foow)r   r   r   r   r   tempfileTemporaryDirectoryospathjoinopenr   r   )Zmissing_file_nameZfind_missing_filetemp_dirZmissing_file_pathZfind_missing_file_againr   r   r   r   r   test_load_resource_not_found&   s     


r   c                 C   sV   t t t }t|  t t| }t t| }||ksBtd||ksRtdd S )NzLast timestamp not accurate.z!Last access time is not accurate.)	r   r   r   r   Zget_timer   Zget_timestampZget_lastaccessr   )r	   starttsZlast_accessr   r   r   test_timestamp_and_lastaccess@   s    
r   c               	   C   s(   t d} t  |   W 5 Q R X d S )Nzkivy.cache.print)r   r   print_usageZassert_called)Z
mock_printr   r   r   test_print_usageL   s    
r!   )__doc__Zpytestr   r   Zunittest.mockr   Z
kivy.cacher   Z
kivy.clockr   Zkivy.resourcesr   r   Zfixturer	   r   r   r   r   r   r!   r   r   r   r   <module>   s   
