o
    il                     @   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'  http2Thttp1keyvalue
   )attempts)	base_urlapi_versionheaderstimeoutclient_argsasync_client_args
extra_bodyretry_optionsbase_url_resource_scope)httpx_clienthttpx_async_clientaiohttp_client)r   HttpOptionsHttpRetryOptionsResourceScope
COLLECTIONr   patch_http_optionsmodel_fieldskeyshasattrgetattrr   r   r   r   r   r   r   r   )patch_optionsoptionspatchedhttp_options_keysr    r)   _/home/ubuntu/.local/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_headers6   s"   r3   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	   r0   z
user-agentzx-goog-api-client)r   r   r   r    r   r1   r)   r)   r*   /test_patch_http_options_appends_version_headersM   s   r4   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_header_   s   
rH   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 )NFr5   r7   r8   i  r6   r:   r;   r=   r>   r?   r9   r@   8rB   rF   r9   rG   r)   r)   r*   &test_timeout_rounded_to_nearest_secondn   s   rM   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 )NFr5   rI   r@   3i*  )r   r   r:   r;   rJ   rB   rL   r)   r)   r*   #test_server_timeout_not_overwritten}   s   rO   c                  C   s0   t jddd} | jddi d}d|jvsJ d S )NFr5   rI   r:   r;   r<   r@   )r   rC   rD   r   rE   r)   r)   r*   &test_server_timeout_not_set_by_default   s   rP   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   r7   r9   )	pytestraises
ValueErrorr   rC   r   r   r   r   r)   r)   r)   r*   1test_resource_scope_without_base_url_raises_error   s   "rU   c                  C   s*   t jdtjddd} | jjd u sJ d S )NTr   )r   rQ   )r   rC   r   r   _http_optionsr   )rF   r)   r)   r*   /test_base_url_resource_scope_not_set_by_default   s   rW   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   rX   )__doc__rR    r   r   r+   r3   r4   rH   rM   rO   rP   rU   rW   rX   r)   r)   r)   r*   <module>   s   
