o
    Yi                     @   sX  U d Z ddlZddlmZ ddlZddlmZ ddlmZ dZej	
ej	ej	ed	Zejd
dejeejjeddddejddejeejjeddejdejjejjddddddidddejddejeejjeddejddddgZeej ed< ejee dedZdd  Zejj d!d" Z!ejj d#d$ Z"ejj d%d& Z#dS )'zTests for upscale_image.    N)ValidationError   )types   )pytest_helperzimagen-4.0-upscale-previewz../data/bridge1.pngZtest_upscale_no_configz&only supported in the Vertex AI clientlocationx2)modelimageupscale_factor)nameexception_if_mldev
parametersZtest_upscaleT
image/jpegP   333333?Zimagen_label_keyupscale_image)include_rai_reasonperson_generationsafety_filter_leveloutput_mime_typeoutput_compression_qualityenhance_input_imageimage_preservation_factorlabelsr
   r   r   configZtest_upscale_gcs!gs://genai-sdk-tests/temp/images/Zoutput_gcs_uri
test_tablezmodels.upscale_image)fileZglobals_for_fileZtest_methodr    c              
   C   sn   z| j jttjjtdddddd J  ty6 } zt|t	s#J dt
|v s+J W Y d }~d S d }~ww 	Nr   r	   Zupscale   )modeZnumber_of_imagesr   FzExtra inputs are not permitted)modelsr   IMAGEN_MODEL_LATESTr   Image	from_fileIMAGE_FILE_PATH	Exception
isinstancer   strcliente r0   f/home/kim/smarthome/.venv/lib/python3.10/site-packages/google/genai/tests/models/test_upscale_image.py$test_upscale_extra_config_parametersS   s   
r2   c                    s   t | t3 | jjjttjj	t
ddtjtjjtjjdddddddI d H }|jd	 jjs2J W d    d S 1 s=w   Y  d S )
Nr   r	   Tr   r   r   )r   r   r   r   r   r   r   r   r   )r   r   
ValueErroraior%   r   r&   r   r'   r(   r)   UpscaleImageConfigPersonGenerationALLOW_ADULTSafetyFilterLevelBLOCK_LOW_AND_ABOVEgenerated_imagesr   Zimage_bytesr.   responser0   r0   r1   test_upscale_asynch   s$   "r=   c                    st   t | t) | jjjttjj	t
ddtjdddI d H }|jd jjs(J W d    d S 1 s3w   Y  d S )Nr   r	   r   r   r   r   )r   r   r3   r4   r%   r   r&   r   r'   r(   r)   r5   r:   r   Zgcs_urir;   r0   r0   r1   test_upscale_gcs_async|   s   "r>   c              
      sx   z| j jjttjjtddddddI d H  J  ty; } zt	|t
s(J dt|v s0J W Y d }~d S d }~ww r"   )r4   r%   r   r&   r   r'   r(   r)   r*   r+   r   r,   r-   r0   r0   r1   *test_upscale_extra_config_parameters_async   s    
r?   )$__doc__osZpydanticr   Zpytest r   r   r&   pathabspathjoindirname__file__r)   ZTestTableItemZUpscaleImageParametersr'   r(   r5   r6   r7   r8   r9   r    list__annotations__setupglobalsZ
pytestmarkr2   markZasyncior=   r>   r?   r0   r0   r0   r1   <module>   s   	*

