1313# limitations under the License.
1414#
1515
16- """Tests for caches.create() and caches.delete()."""
16+ """Tests for caches.create(), caches.get(), and caches.delete()."""
1717
1818from .... import types as genai_types
1919from ... import pytest_helper
2020
2121
22- def create_delete (client , parameters ):
23- cache = client .caches .create (
24- model = parameters .model ,
25- config = parameters .config ,
26- )
27- client .caches .delete (name = cache .name )
22+ def create_get_delete (client , parameters ):
23+ if client .vertexai :
24+ cache = client .caches .create (
25+ model = parameters .model ,
26+ config = parameters .config ,
27+ )
28+ else :
29+ # For MLDev, we must create the file before creating the cache.
30+ file = client .files .upload (file = "tests/data/a-man-and-a-dog.png" )
31+ config = genai_types .CreateCachedContentConfig (
32+ contents = [
33+ genai_types .Part .from_uri (
34+ file_uri = file .uri ,
35+ mime_type = file .mime_type ,
36+ )
37+ ]
38+ * 5
39+ )
40+ cache = client .caches .create (model = parameters .model , config = config )
41+ got_cache = client .caches .get (name = cache .name )
42+ client .caches .delete (name = got_cache .name )
2843
2944
3045test_table : list [pytest_helper .TestTableItem ] = [
3146 pytest_helper .TestTableItem (
32- name = "test_create_delete_vertex " ,
47+ name = "test_create_get_delete " ,
3348 parameters = genai_types ._CreateCachedContentParameters (
3449 model = "gemini-2.5-flash" ,
3550 config = genai_types .CreateCachedContentConfig (
@@ -39,14 +54,13 @@ def create_delete(client, parameters):
3954 )] * 5
4055 ),
4156 ),
42- exception_if_mldev = "unsupported" ,
4357 ),
4458]
4559
4660pytestmark = pytest_helper .setup (
4761 file = __file__ ,
4862 globals_for_file = globals (),
49- test_method = "create_delete " ,
63+ test_method = "create_get_delete " ,
5064 test_table = test_table ,
5165)
5266
0 commit comments