o
    Yi                     @   sx   d Z ddlZddlmZ ddlmZ dd Zdd	 Zd
d Zdd Zdd Z	dd Z
dd Zdd Zdd Zdd ZdS )z0Tests for client behavior when issuing requests.    N   )_api_client)typesc                  C   s   t jddddidddiddid	d
it jddt jjd	} t  }t|| }t jj }|D ]}t	||s7J |dvrDt
||d usDJ q.|jdksLJ |jdksSJ |jd dks\J |jdkscJ |jjdkskJ |jd srJ |jd syJ d S )Nhttps://fake-url.com/v1X-Custom-Headercustom_value'  Zhttp2TZhttp1keyvalue
   )attempts)	base_urlapi_versionheaderstimeoutclient_argsasync_client_argsZ
extra_bodyretry_optionsbase_url_resource_scope)Zhttpx_clientZhttpx_async_clientZaiohttp_client)r   HttpOptionsZHttpRetryOptionsResourceScope
COLLECTIONr   patch_http_optionsZmodel_fieldskeyshasattrgetattrr   r   r   r   r   r   r   r   )patch_optionsoptionspatchedZhttp_options_keysr
    r    e/home/kim/smarthome/.venv/lib/python3.10/site-packages/google/genai/tests/client/test_http_options.py.test_patch_http_options_with_copies_all_fields   s4   
r"   c                  C   s   t jdddd} t jddddidd	}t| |}|jd dks#J |jd
 dks,J |jdks3J |jdks:J |jdksAJ d S )Ndifferent_valuer   X-different-headerr   r   r   r   r   r	   r   r   r   r   r%   )r   r   r   r   r   r   r   r   original_optionsr   r   r    r    r!   &test_patch_http_options_merges_headers:   s"   r*   c                  C   sT   t jdddd} t jddddidd	}t| |}d
|jv s!J d|jv s(J d S )Nr#   r$   r&   r   r   r   r   r	   r'   z
user-agentzx-goog-api-client)r   r   r   r   r   r(   r    r    r!   /test_patch_http_options_appends_version_headersQ   s   r+   c                  C   sL   t jddtjddd} | jddi d}d	|jv sJ |jd	 d
ks$J d S )NFtest_api_keyr	   r   )vertexaiapi_keyhttp_optionsPOSTsample/pathhttp_methodpathrequest_dictX-Server-Timeout10r   BaseApiClientr   r   _build_requestr   
api_clientrequestr    r    r!   4test_setting_timeout_populates_server_timeout_headerc   s   
r?   c                  C   sB   t jddd} tjdd}| jddi |d}|jd	 d
ksJ d S )NFr,   r.   r/   i  r-   r1   r2   r4   r5   r6   r0   r7   8r9   r=   r0   r>   r    r    r!   &test_timeout_rounded_to_nearest_secondr   s   rD   c                  C   sH   t jddd} tjddidd}| jdd	i |d
}|jd dks"J d S )NFr,   r@   r7   3i*  )r   r   r1   r2   rA   r9   rC   r    r    r!   #test_server_timeout_not_overwritten   s   rF   c                  C   s0   t jddd} | jddi d}d|jvsJ d S )NFr,   r@   r1   r2   r3   r7   )r   r:   r;   r   r<   r    r    r!   &test_server_timeout_not_set_by_default   s   rG   c                   C   sJ   t t tjdtjtjjdd W d    d S 1 sw   Y  d S )NT)r   r.   r0   )	pytestZraises
ValueErrorr   r:   r   r   r   r   r    r    r    r!   1test_resource_scope_without_base_url_raises_error   s   "rK   c                  C   s*   t jdtjddd} | jjd u sJ d S )NTr   )r   rH   )r   r:   r   r   Z_http_optionsr   )r=   r    r    r!   /test_base_url_resource_scope_not_set_by_default   s   rL   c                  C   s   t  } | jd u sJ d S )N)r   r   r   )r   r    r    r!   %test_retry_options_not_set_by_default   s   rM   )__doc__rI    r   r   r"   r*   r+   r?   rD   rF   rG   rK   rL   rM   r    r    r    r!   <module>   s   !
