o
    Yi                     @   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_KEYZgoogle_api_key)Zsetenvr   monkeypatch r   h/home/kim/smarthome/.venv/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_clientZ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\      
r3   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!   r-   r.   r%   ztest-goog-api-clientr/   r"   r#   r$   r1   r)   r   r   r	   5test_build_request_appends_to_goog_api_client_headersn   r4   r5   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!   r-   r.   r/   r$   r%   )	r   Zappend_library_version_headersr
   r&   r   r'   r   r2   r(   )r   Zheaders_to_injectr*   r+   r   r   r	   ,test_build_request_keeps_sdk_version_headers   s$   

r6   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ZraisingGEMINI_API_KEYGOOGLE_CLOUD_PROJECTGOOGLE_CLOUD_LOCATIONThttps://custom-base-url.comr   Z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   r2   ZResourceScopeZ
COLLECTIONr&   r   r'   urlr   clientr+   r   r   r	   &test_build_request_with_resource_scope   s"   rH   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   Fr7   r8   r9   r:   Tztest-projectztest-locationr;   r<   )r>   projectlocationr?   r@   rA   r    r!   rB   rC   rF   r   r   r	   @test_build_request_with_resource_scope_with_project_and_location   s&   
rK   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   Fr7   r8   r9   r:   Tr;   AuthorizationzBearer fake_access_token)r   r(   r=   )rD   r   r   r2   r   r   r   r	   build_test_client_no_env_vars   s   rM   c                 C   s0   t | jj}|ddddi}|jdksJ d S )Nr   r   r    r!   r;   )rM   r&   r   r'   rE   r)   r   r   r	   3test_build_request_with_custom_base_url_no_env_vars   s   
rN   N)__doc__ r   r   r   r   r
   r   r   r   r   r   r   r,   r3   r5   r6   rH   rK   rM   rN   r   r   r   r	   <module>   s&   							