File tree 2 files changed +22
-0
lines changed 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change 35
35
TEST_JPG_URL = "https://storage.googleapis.com/generativeai-downloads/data/test_img.jpg"
36
36
TEST_JPG_DATA = TEST_JPG_PATH .read_bytes ()
37
37
38
+ TEST_WEBP_PATH = HERE / "test_img.webp"
39
+ TEST_WEBP_DATA = TEST_WEBP_PATH .read_bytes ()
40
+
38
41
39
42
# simple test function
40
43
def datetime ():
Original file line number Diff line number Diff line change 28
28
from google .generativeai import protos
29
29
from absl .testing import parameterized
30
30
31
+ HERE = pathlib .Path (__file__ ).parent
32
+ TEST_PNG_PATH = HERE / "test_img.png"
33
+ TEST_PNG_URL = "https://storage.googleapis.com/generativeai-downloads/data/test_img.png"
34
+ TEST_PNG_DATA = TEST_PNG_PATH .read_bytes ()
35
+
36
+ TEST_JPG_PATH = HERE / "test_img.jpg"
37
+ TEST_JPG_URL = "https://storage.googleapis.com/generativeai-downloads/data/test_img.jpg"
38
+ TEST_JPG_DATA = TEST_JPG_PATH .read_bytes ()
39
+
40
+ TEST_WEBP_PATH = HERE / "test_img.webp"
41
+ TEST_WEBP_DATA = TEST_WEBP_PATH .read_bytes ()
42
+
31
43
32
44
class FileServiceClient (client_lib .FileServiceClient ):
33
45
def __init__ (self , test ):
@@ -139,3 +151,10 @@ def test_video_metadata(self):
139
151
def test_to_file_data (self , file_data ):
140
152
file_data = file_types .to_file_data (file_data )
141
153
self .assertEqual (protos .FileData (file_uri = "https://test_uri" ), file_data )
154
+
155
+ def test_webp_mimetype (self ):
156
+ self .responses ["create_file" ].append (protos .File ())
157
+
158
+ response = genai .upload_file ("test.webp" )
159
+
160
+ self .assertEqual ("image/webp" , self .observed_requests [0 ]["mime_type" ])
You can’t perform that action at this time.
0 commit comments