22
22
import json
23
23
import mock
24
24
import pytest
25
- from vertexai .preview import caching
25
+ from vertexai .caching import _caching
26
26
from google .cloud .aiplatform import initializer
27
27
import vertexai
28
28
from google .cloud .aiplatform_v1beta1 .types .cached_content import (
@@ -141,7 +141,7 @@ def list_cached_contents(self, request):
141
141
142
142
@pytest .mark .usefixtures ("google_auth_mock" )
143
143
class TestCaching :
144
- """Unit tests for caching .CachedContent."""
144
+ """Unit tests for _caching .CachedContent."""
145
145
146
146
def setup_method (self ):
147
147
vertexai .init (
@@ -156,7 +156,7 @@ def test_constructor_with_full_resource_name(self, mock_get_cached_content):
156
156
full_resource_name = (
157
157
"projects/123/locations/europe-west1/cachedContents/contents-id"
158
158
)
159
- cache = caching .CachedContent (
159
+ cache = _caching .CachedContent (
160
160
cached_content_name = full_resource_name ,
161
161
)
162
162
@@ -166,7 +166,7 @@ def test_constructor_with_full_resource_name(self, mock_get_cached_content):
166
166
def test_constructor_with_only_content_id (self , mock_get_cached_content ):
167
167
partial_resource_name = "contents-id"
168
168
169
- cache = caching .CachedContent (
169
+ cache = _caching .CachedContent (
170
170
cached_content_name = partial_resource_name ,
171
171
)
172
172
@@ -179,7 +179,7 @@ def test_constructor_with_only_content_id(self, mock_get_cached_content):
179
179
def test_get_with_content_id (self , mock_get_cached_content ):
180
180
partial_resource_name = "contents-id"
181
181
182
- cache = caching .CachedContent .get (
182
+ cache = _caching .CachedContent .get (
183
183
cached_content_name = partial_resource_name ,
184
184
)
185
185
@@ -192,7 +192,7 @@ def test_get_with_content_id(self, mock_get_cached_content):
192
192
def test_create_with_real_payload (
193
193
self , mock_create_cached_content , mock_get_cached_content
194
194
):
195
- cache = caching .CachedContent .create (
195
+ cache = _caching .CachedContent .create (
196
196
model_name = "model-name" ,
197
197
system_instruction = GapicContent (
198
198
role = "system" , parts = [GapicPart (text = "system instruction" )]
@@ -219,7 +219,7 @@ def test_create_with_real_payload(
219
219
def test_create_with_real_payload_and_wrapped_type (
220
220
self , mock_create_cached_content , mock_get_cached_content
221
221
):
222
- cache = caching .CachedContent .create (
222
+ cache = _caching .CachedContent .create (
223
223
model_name = "model-name" ,
224
224
system_instruction = "Please answer my questions with cool" ,
225
225
tools = [],
@@ -239,15 +239,15 @@ def test_create_with_real_payload_and_wrapped_type(
239
239
assert cache .display_name == _TEST_DISPLAY_NAME
240
240
241
241
def test_list (self , mock_list_cached_contents ):
242
- cached_contents = caching .CachedContent .list ()
242
+ cached_contents = _caching .CachedContent .list ()
243
243
for i , cached_content in enumerate (cached_contents ):
244
244
assert cached_content .name == f"cached_content{ i + 1 } _from_list_request"
245
245
assert cached_content .model_name == f"model-name{ i + 1 } "
246
246
247
247
def test_print_a_cached_content (
248
248
self , mock_create_cached_content , mock_get_cached_content
249
249
):
250
- cached_content = caching .CachedContent .create (
250
+ cached_content = _caching .CachedContent .create (
251
251
model_name = "model-name" ,
252
252
system_instruction = "Please answer my questions with cool" ,
253
253
tools = [],
0 commit comments