o
    i                     @   s   d Z ddlm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d Zdd Zdd Zdd  Zd!d" Zd#S )$z0Tests for client behavior when issuing requests.   )_api_client)Client)typesc                 C   s   |  dd t S )NGOOGLE_API_KEYgoogle_api_key)setenvr   monkeypatch r
   b/home/ubuntu/.local/lib/python3.10/site-packages/google/genai/tests/client/test_client_requests.pybuild_test_client   s   r   c                  C       d} d}t | |dksJ d S )Nhttps://fake-url.com/some_path//v1beta/models,https://fake-url.com/some_path/v1beta/models
api_clientjoin_url_pathbase_urlpathr
   r
   r   Ktest_join_url_path_base_url_with_trailing_slash_and_path_with_leading_slash   
   
r   c                  C   r   )Nr   v1beta/modelsr   r   r   r
   r
   r   Stest_join_url_path_with_base_url_with_trailing_slash_and_path_without_leading_slash&   r   r   c                  C   r   )Nhttps://fake-url.com/some_pathr   r   r   r   r
   r
   r   Stest_join_url_path_with_base_url_without_trailing_slash_and_path_with_leading_slash/   r   r   c                  C   r   )Nr   r   r   r   r   r
   r
   r   Vtest_join_url_path_with_base_url_without_trailing_slash_and_path_without_leading_slash8   r   r   c                  C   r   )Nzhttps://fake-url.com/r   "https://fake-url.com/v1beta/modelsr   r   r
   r
   r   <test_join_url_path_base_url_without_path_with_trailing_slashA   r   r   c                  C   r   )Nzhttps://fake-url.comr   r   r   r   r
   r
   r   ?test_join_url_path_base_url_without_path_without_trailing_slashJ   r   r    c                 C   sj   t | jj}|ddddi}d|jd v sJ d|jd v s!J d|jd v s*J d|jd v s3J d S )	NGET	test/pathkeyvaluegoogle-genai-sdk/
user-agent
gl-python/x-goog-api-client)r   modelsr   _build_requestheadersr	   request_clientrequestr
   r
   r   /test_build_request_sets_library_version_headersS   s   r/   c              
   C   s|   t | jj}|dddditjddddid	}d|jd v s!J d
|jd v s*J d|jd v s3J d
|jd v s<J d S )Nr!   r"   r#   r$   test/url1r&   ztest-user-agentr   api_versionr+   r%   r'   r(   r   r)   r   r*   r   HttpOptionsDictr+   r,   r
   r
   r   0test_build_request_appends_to_user_agent_headers\      
r6   c              
   C   s|   t | jj}|dddditjddddid	}d
|jd v s!J d|jd v s*J d
|jd v s3J d|jd v s<J d S )Nr!   r"   r#   r$   r0   r1   r(   ztest-goog-api-clientr2   r%   r&   r'   r4   r,   r
   r
   r   5test_build_request_appends_to_goog_api_client_headersn   r7   r8   c              
   C   s   i }t | d|d v sJ t| jj}|dddditjdd|d	}d|jd v s.J d
|jd v s7J d|jd v s@J d
|jd v sIJ d S )Nr%   r&   r!   r"   r#   r$   r0   r1   r2   r'   r(   )	r   append_library_version_headersr   r)   r   r*   r   r5   r+   )r	   headers_to_injectr-   r.   r
   r
   r   ,test_build_request_keeps_sdk_version_headers   s$   

r;   c                 C   sz   | j ddd | j ddd | j ddd | j ddd tdtjdtjjd	d
}|jjddddi}|j	dks;J d S )Nr   FraisingGEMINI_API_KEYGOOGLE_CLOUD_PROJECTGOOGLE_CLOUD_LOCATIONThttps://custom-base-url.comr   base_url_resource_scopevertexaihttp_optionspost-publishers/google/models/gemini-3-pro-previewr#   r$   Ihttps://custom-base-url.com/publishers/google/models/gemini-3-pro-preview
delenvr   r   r5   ResourceScope
COLLECTIONr)   r   r*   urlr	   clientr.   r
   r
   r   &test_build_request_with_resource_scope   s"   rQ   c                 C   s~   | j ddd | j ddd | j ddd | j ddd tddd	tjd
tjjdd}|jjddddi}|j	dks=J d S )Nr   Fr<   r>   r?   r@   Tztest-projectztest-locationrA   rB   )rE   projectlocationrF   rG   rH   r#   r$   rI   rJ   rO   r
   r
   r   @test_build_request_with_resource_scope_with_project_and_location   s&   
rT   c                 C   sR   | j ddd | j ddd | j ddd | j ddd tdtjdd	d
iddS )Nr   Fr<   r>   r?   r@   TrA   AuthorizationzBearer fake_access_token)r   r+   rD   )rK   r   r   r5   r   r
   r
   r   build_test_client_no_env_vars   s   rV   c                 C   s0   t | jj}|ddddi}|jdksJ d S )Nr!   r"   r#   r$   rA   )rV   r)   r   r*   rN   r,   r
   r
   r   3test_build_request_with_custom_base_url_no_env_vars   s   
rW   N)__doc__ r   r   r   r   r   r   r   r   r   r   r    r/   r6   r8   r;   rQ   rT   rV   rW   r
   r
   r
   r   <module>   s&   							