
    Cad;	                     ^    d Z ddlZddlmZ ddlmZ ddlmZ  G d dej                        Z	y)zTests for stevedore._cache
    N)mock)_cache)utilsc                   x    e Zd Zd Zd Z ej                  d       ej                  d      d               Zd Zy)	TestCachec                     t         j                  j                  t        dd      5  t	        j
                         }| j                  |j                         ddd       y# 1 sw Y   yxY w)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sots     </usr/lib/python3/dist-packages/stevedore/tests/test_cache.pytest_disable_caching_executablez)TestCache.test_disable_caching_executable   sL     ZZsL+> 	2,,.COOC001	2 	2 	2s   0AA(c                    t        j                         }t        j                  d      5 }d|_        t        j
                         }|j                  d|z         | j                  |j                         d|_        t        j
                         }| j                  |j                         ddd       y# 1 sw Y   yxY w)zSTest caching is disabled if .disable file is present in target
        dir
        zos.path.isfileTz%s/.disableFN)
r   _get_cache_dirr   r
   return_valuer   assert_called_withr   r   assertFalse)r   	cache_dir	mock_pathr   s       r   test_disable_caching_filez#TestCache.test_disable_caching_file!   s     ))+	ZZ() 	3Y%)I",,.C(()BCOOC001%*I",,.CS112	3 	3 	3s   BB44B=zos.makedirszbuiltins.openc                     t        j                         }d|_        t        |_        |j                  d       |j                          y )NTfake)r   r   r   IOErrorside_effect_get_data_for_pathassert_not_called)r   	mock_open
mock_mkdirr   s       r    test__get_data_for_path_no_writez*TestCache.test__get_data_for_path_no_write1   s9     lln# '	v&$$&    c                 ^    t        j                         }| j                  |d   t               y )Ngroups)r   _build_cacheable_dataassertIsInstancedict)r   rets     r   test__build_cacheable_dataz$TestCache.test__build_cacheable_data:   s&    
 **,c(mT2r%   N)	__name__
__module____qualname__r   r   r   r
   r$   r,    r%   r   r   r      sC    23  TZZTZZ ' ! '3r%   r   )
__doc__r   unittestr   	stevedorer   stevedore.testsr   TestCaser   r0   r%   r   <module>r6      s&    
   !)3 )3r%   