
    tni                     4    d Z ddlZddlZ G d d          ZdS )z:Tests for runpod.serverless.utils.__init__ module exports.    Nc                   H    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 ZdS )TestServerlessUtilsInitz4Test runpod.serverless.utils module __all__ exports.c                     t          t          j        j        d          sJ t	          t          j        j        j        t                    sJ t          t          j        j        j                  dk    sJ dS )z+Test that __all__ is defined in the module.__all__r   N)hasattrrunpod
serverlessutils
isinstancer   listlenselfs    b/var/www/html/gpu-tools/venv/lib/python3.11/site-packages/tests/test_serverless/test_utils_init.pytest_all_definedz(TestServerlessUtilsInit.test_all_defined
   se    v(.	:::::&+194@@@@@6$*233a777777    c                     t           j        j        j        D ]/}t	          t           j        j        |          sJ d| d            0dS )z9Test that all symbols in __all__ are actually importable.zSymbol 'z$' in __all__ but not found in moduleN)r   r	   r
   r   r   )r   symbols     r   test_all_symbols_importablez3TestServerlessUtilsInit.test_all_symbols_importable   s[    '-5 	u 	uF6,2F;;tt=t=t=t=ttttt	u 	ur   c                     h d}t          t          j        j        j                  }||k    sJ d| d|             dS )z1Test that expected public symbols are in __all__.>   upload_file_to_bucketupload_in_memory_objectdownload_files_from_urls	Expected , got N)setr   r	   r
   r   )r   expected_symbolsactual_symbolss      r   test_expected_public_symbolsz4TestServerlessUtilsInit.test_expected_public_symbols   s^    
 
 

 V.4<==>1113g?O3g3gWe3g3g11111r   c                     g d}|D ]k}|t           j        j        j        v sJ t	          t           j        j        |          sJ t          t          t           j        j        |                    sJ ldS )z8Test that utility functions are accessible and callable.)r   r   r   N)r   r	   r
   r   r   callablegetattr)r   utility_functions	func_names      r   !test_utility_functions_accessiblez9TestServerlessUtilsInit.test_utility_functions_accessible   s    
 
 
 + 	I 	II 1 7 ?????6,2I>>>>>GF$5$;YGGHHHHHH	I 	Ir   c                     t           j        j        j        }t	          j        |          }t          |j                  dk    sJ dS )z3Test that download function has expected signature.r   N)r   r	   r
   r   inspect	signaturer   
parameters)r   funcsigs      r    test_download_function_signaturez8TestServerlessUtilsInit.test_download_function_signature,   sA     &?%%3>""Q&&&&&&r   c                     t           j        j        j        t           j        j        j        g}|D ]0}t          j        |          }t          |j                  dk    sJ 1dS )z4Test that upload functions have expected signatures.r   N)	r   r	   r
   r   r   r'   r(   r   r)   )r   upload_funcsr*   r+   s       r    test_upload_functions_signaturesz8TestServerlessUtilsInit.test_upload_functions_signatures3   sl     #9#;

 ! 	+ 	+D#D))Cs~&&*****	+ 	+r   c                     t           j        j        j        t	                    }t                    t          |          k    sJ dfdD                          dS )z0Test that __all__ contains no duplicate symbols.zDuplicates found in __all__: c                 F    g | ]}                     |          d k    |S )   )count).0xall_symbolss     r   
<listcomp>zLTestServerlessUtilsInit.test_no_duplicate_symbols_in_all.<locals>.<listcomp>C   sn      YM  YM  YM_`s~  tE  tE  FG  tH  tH  KL  tL  tLYZ  tL  tL  tLr   N)r   r	   r
   r   r   r   )r   unique_symbolsr6   s     @r    test_no_duplicate_symbols_in_allz8TestServerlessUtilsInit.test_no_duplicate_symbols_in_all?   s    '-5[));3~#6#6666  9O  YM  YM  YM  YMdo  YM  YM  YM  9O  9O66666r   c                 @   d t          t          j        j                  D             }t	                      }||z
  }t	          t          j        j        j                  }|                    |          sJ d||z
               h d}||k    sJ d| d|             dS )z8Test that __all__ contains only the intended public API.c                 <    h | ]}|                     d           |S )_)
startswith)r4   names     r   	<setcomp>zJTestServerlessUtilsInit.test_all_covers_public_api_only.<locals>.<setcomp>H   s8     4 4 4"ooc224 4 4 4r   z%__all__ contains non-public symbols: >   r   r   r   r   r   N)dirr   r	   r
   r   r   issubset)r   module_attrsexpected_private_attrspublic_attrsr6   expected_public_apis         r   test_all_covers_public_api_onlyz7TestServerlessUtilsInit.test_all_covers_public_api_onlyE   s    4 4V->-D)E)E 4 4 4 "%#&<<&+19:: ##L11ww3w[fiu[u3w3wwww
 
 

 11113g?R3g3gZe3g3g11111r   c                     t          t          j        j        d          sJ t          t          j        j        d          sJ t          t          j        j        d          sJ dS )z;Test that functions are imported from the expected modules.r   r   r   N)r   r   r	   r
   r   s    r   #test_functions_from_correct_modulesz;TestServerlessUtilsInit.test_functions_from_correct_modules\   sa    
 v(.0JKKKKKv(.0GHHHHHv(.0IJJJJJJJr   N)__name__
__module____qualname____doc__r   r   r   r%   r,   r/   r9   rF   rH    r   r   r   r      s        >>8 8 8u u u
h h hI I I' ' '
+ 
+ 
+O O Oh h h.K K K K Kr   r   )rL   r'   runpod.serverless.utilsr   r   rM   r   r   <module>rO      sf    @ @     \K \K \K \K \K \K \K \K \K \Kr   