
    >hE                         d Z ddlmZ  G d de      Z G d de      Zd Z e       Z[ G d d	e      Z G d
 de      Z	y)zShared testing utilities.    )absolute_importc                   "    e Zd ZdZd Zd Zd Zy)_MonkeyzBContext-manager for replacing module names in the scope of a test.c                     || _         |st        d      |D ci c]  }|t        ||       c}| _        |j	                         D ]  \  }}t        |||        y c c}w )Nz-_Monkey was used with nothing to monkey-patch)module
ValueErrorgetattr
to_restoreitemssetattr)selfr   kwkeyvalues        b/var/www/html/DP/alpha_backend/venv/lib/python3.12/site-packages/google/cloud/_testing/__init__.py__init__z_Monkey.__init__   s`    LMM@BC3 44C((*JCFC' % Ds   Ac                     | S N r   s    r   	__enter__z_Monkey.__enter__           c                 v    | j                   j                         D ]  \  }}t        | j                  ||        y r   )r
   r   r   r   )r   exc_typeexc_valexc_tbr   r   s         r   __exit__z_Monkey.__exit__"   s-    ////1JCDKKe, 2r   N)__name__
__module____qualname____doc__r   r   r   r   r   r   r   r      s    L(-r   r   c                        e Zd ZddZd Zd Zy)_NamedTemporaryFilec                 j    dd l }dd l}|j                  |      \  }| _        |j	                  |       y )Nr   )suffix)ostempfilemkstempnameclose)r   r&   r'   r(   
filehandles        r   r   z_NamedTemporaryFile.__init__(   s.     ( 0 0 0 ?
DI
r   c                     | S r   r   r   s    r   r   z_NamedTemporaryFile.__enter__/   r   r   c                 B    dd l }|j                  | j                         y )Nr   )r'   remover*   )r   r   r   r   r'   s        r   r   z_NamedTemporaryFile.__exit__2   s    
		$))r   N) )r   r    r!   r   r   r   r   r   r   r$   r$   '   s    r   r$   c                  L    dd l } dd ldd l| j                  fd       }|S )Nr   c               3   X   K   j                         } |  j                  |        y wr   )mkdtemprmtree)temp_dirshutilr(   s    r   _tempdir_mgrz$_tempdir_maker.<locals>._tempdir_mgr=   s&     ##%hs   '*)
contextlibr6   r(   contextmanager)r8   r7   r6   r(   s     @@r   _tempdir_makerr:   8   s,       
 r   c                   @    e Zd ZdZd Zed	d       Zd Zd Zd Z	d Z
y)
_GAXBaseAPIFc                 :    | j                   j                  |       y r   )__dict__update)r   r   s     r   r   z_GAXBaseAPI.__init__Q   s    R r   Nc                 L    ddl m} ddlm} d} |dd || |      } ||d d d       S )Nr   )	_RPCState)GrpcRendezvouszSome error details.r   )grpc._channelrA   google.cloud.exceptionsrB   )status_codetrailingrA   rB   details	exc_states         r   _make_grpc_errorz_GAXBaseAPI._make_grpc_errorT   s0    +:'b$+wG	itT::r   c                 D    ddl m} | j                  |j                        S Nr   )
StatusCode)grpcrL   rI   	NOT_FOUNDr   rL   s     r   _make_grpc_not_foundz _GAXBaseAPI._make_grpc_not_found]   s    #$$Z%9%9::r   c                 D    ddl m} | j                  |j                        S rK   )rM   rL   rI   FAILED_PRECONDITIONrO   s     r   _make_grpc_failed_preconditionz*_GAXBaseAPI._make_grpc_failed_preconditionb   s    #$$Z%C%CDDr   c                 D    ddl m} | j                  |j                        S rK   )rM   rL   rI   ALREADY_EXISTSrO   s     r   _make_grpc_already_existsz%_GAXBaseAPI._make_grpc_already_existsg   s    #$$Z%>%>??r   c                 D    ddl m} | j                  |j                        S rK   )rM   rL   rI   DEADLINE_EXCEEDEDrO   s     r   _make_grpc_deadline_exceededz(_GAXBaseAPI._make_grpc_deadline_exceededl   s    #$$Z%A%ABBr   r   )r   r    r!   _random_gax_errorr   staticmethodrI   rP   rS   rV   rY   r   r   r   r<   r<   N   s8    ! ; ;;
E
@
Cr   r<   c                       e Zd Zd Zd Zy)_GAXPageIteratorc                 P    t        |      | _        |j                  d      | _        y )N
page_token)iter_pagesgetr_   )r   pageskwargss      r   r   z_GAXPageIterator.__init__s   s    5k **\2r   c                 ,    t        | j                        S )zIterate to the next page.)nextra   r   s    r   __next__z_GAXPageIterator.__next__w   s    DKK  r   N)r   r    r!   r   rg   r   r   r   r]   r]   r   s    3!r   r]   N)
r"   
__future__r   objectr   r$   r:   _tempdirr<   r]   r   r   r   <module>rk      sR      &-f -&& "" !C& !CH!v !r   