U
    [e;	                     @   sF   d Z ddlZddlmZ ddlmZ ddlmZ G dd dejZ	dS )zTests for stevedore._cache
    N)mock)_cache)utilsc                   @   s@   e Zd Zdd Zdd Zededdd Zd	d
 ZdS )	TestCachec              	   C   s4   t jtdd t }| |j W 5 Q R X dS )ziTest caching is disabled if python interpreter is located under /tmp
        directory (Ansible)
        
executablez	/tmp/fakeN)r   patchobjectsysr   Cache
assertTrue_disable_caching)selfsot r   \/var/www/html/services/stratfitenv/lib/python3.8/site-packages/stevedore/tests/test_cache.pytest_disable_caching_executable   s    z)TestCache.test_disable_caching_executablec              	   C   sd   t  }tdH}d|_t  }|d|  | |j d|_t  }| 	|j W 5 Q R X dS )zSTest caching is disabled if .disable file is present in target
        dir
        zos.path.isfileTz%s/.disableFN)
r   _get_cache_dirr   r   Zreturn_valuer
   Zassert_called_withr   r   ZassertFalse)r   	cache_dirZ	mock_pathr   r   r   r   test_disable_caching_file!   s    z#TestCache.test_disable_caching_filezos.makedirszbuiltins.openc                 C   s*   t  }d|_t|_|d |  d S )NTZfake)r   r
   r   IOErrorZside_effectZ_get_data_for_pathZassert_not_called)r   Z	mock_openZ
mock_mkdirr   r   r   r    test__get_data_for_path_no_write1   s
    
z*TestCache.test__get_data_for_path_no_writec                 C   s   t  }| |d t d S )Ngroups)r   Z_build_cacheable_dataZassertIsInstancedict)r   retr   r   r   test__build_cacheable_data:   s    z$TestCache.test__build_cacheable_dataN)	__name__
__module____qualname__r   r   r   r   r   r   r   r   r   r   r      s   r   )
__doc__r	   Zunittestr   Z	stevedorer   Zstevedore.testsr   ZTestCaser   r   r   r   r   <module>   s
   