diff --git a/google/genai/tests/conftest.py b/google/genai/tests/conftest.py index 03b813631..ecdf523e4 100644 --- a/google/genai/tests/conftest.py +++ b/google/genai/tests/conftest.py @@ -61,6 +61,12 @@ def replays_prefix(): return 'test' +# Overridden at the module level for each test file. +@pytest.fixture +def location(): + return None + + def _get_replay_id(use_vertex: bool, replays_prefix: str) -> str: test_name_ending = os.environ.get('PYTEST_CURRENT_TEST').split('::')[-1] test_name = ( @@ -72,7 +78,7 @@ def _get_replay_id(use_vertex: bool, replays_prefix: str) -> str: @pytest.fixture -def client(use_vertex, replays_prefix, http_options, request): +def client(use_vertex, replays_prefix, http_options, location, request): mode = request.config.getoption('--mode') if mode not in ['auto', 'record', 'replay', 'api', 'tap']: raise ValueError('Invalid mode: ' + mode) @@ -121,6 +127,7 @@ def client(use_vertex, replays_prefix, http_options, request): vertexai=use_vertex, http_options=http_options, private=private, + location=location, ) with mock.patch.object( diff --git a/google/genai/tests/pytest_helper.py b/google/genai/tests/pytest_helper.py index 17076cd82..510b67c4f 100644 --- a/google/genai/tests/pytest_helper.py +++ b/google/genai/tests/pytest_helper.py @@ -143,6 +143,7 @@ def setup( test_method: Optional[str] = None, test_table: Optional[list[TestTableItem]] = None, http_options: Optional[HttpOptions] = None, + location: Optional[str] = None, ): """Generates parameterization for tests, run for both Vertex and MLDev.""" replays_directory = ( @@ -192,10 +193,10 @@ def setup( # Add fixture for requested client option. return pytest.mark.parametrize( - 'use_vertex, replays_prefix, http_options', + 'use_vertex, replays_prefix, http_options, location', [ - (True, replays_directory, http_options), - (False, replays_directory, http_options), + (True, replays_directory, http_options, location), + (False, replays_directory, http_options, location), ], ) diff --git a/google/genai/tests/shared/__init__.py b/google/genai/tests/shared/__init__.py index 880bf22d8..991599436 100644 --- a/google/genai/tests/shared/__init__.py +++ b/google/genai/tests/shared/__init__.py @@ -13,4 +13,4 @@ # limitations under the License. # -GEMINI_MODEL = 'gemini-3.1-pro-preview' # Gemini only +GEMINI_MODEL = 'gemini-3.5-flash' # Gemini only diff --git a/google/genai/tests/shared/batches/test_create_delete.py b/google/genai/tests/shared/batches/test_create_delete.py index 5fe17d0b2..afd1ffced 100644 --- a/google/genai/tests/shared/batches/test_create_delete.py +++ b/google/genai/tests/shared/batches/test_create_delete.py @@ -44,9 +44,7 @@ def create_delete(client, parameters): }] }], ), - exception_if_vertex=( - "not supported in Gemini Enterprise Agent Platform." - ), + exception_if_vertex="only supported in Gemini Developer", ), ] diff --git a/google/genai/tests/shared/batches/test_create_get_cancel.py b/google/genai/tests/shared/batches/test_create_get_cancel.py index b54fcc5a0..6da569bc0 100644 --- a/google/genai/tests/shared/batches/test_create_get_cancel.py +++ b/google/genai/tests/shared/batches/test_create_get_cancel.py @@ -43,7 +43,7 @@ def create_get_cancel(client, parameters): }] }], ), - exception_if_vertex="Exactly one of ", + exception_if_vertex="only supported in Gemini Developer", ), ] diff --git a/google/genai/tests/shared/files/test_upload_get_delete.py b/google/genai/tests/shared/files/test_upload_get_delete.py index 0f3c6a007..483574dec 100644 --- a/google/genai/tests/shared/files/test_upload_get_delete.py +++ b/google/genai/tests/shared/files/test_upload_get_delete.py @@ -40,7 +40,7 @@ def upload_get_delete(client, parameters): parameters=_UploadGetDeleteParameters( file_path="tests/data/google.png", ), - exception_if_vertex='only supported in the Gemini Developer client', + exception_if_vertex="only supported in the Gemini Developer", ), ] diff --git a/google/genai/tests/shared/models/test_embed.py b/google/genai/tests/shared/models/test_embed.py index 910cb65f7..081f02839 100644 --- a/google/genai/tests/shared/models/test_embed.py +++ b/google/genai/tests/shared/models/test_embed.py @@ -34,7 +34,7 @@ pytest_helper.TestTableItem( name='test_embed_gemini_embedding_2', parameters=genai_types.EmbedContentParameters( - model='gemini-embedding-2-preview', + model='gemini-embedding-2', contents='Hello world!', config={ 'output_dimensionality': 10, diff --git a/google/genai/tests/shared/tunings/__init__.py b/google/genai/tests/shared/tunings/__init__.py index 67ab1fbc1..8dc7d5688 100644 --- a/google/genai/tests/shared/tunings/__init__.py +++ b/google/genai/tests/shared/tunings/__init__.py @@ -11,5 +11,4 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -# GEMINI_TUNABLE_MODEL = 'gemini-3.1-flash-lite' -GEMINI_TUNABLE_MODEL = 'gemini-2.5-pro' +GEMINI_TUNABLE_MODEL = 'gemini-3.5-flash' diff --git a/google/genai/tests/shared/tunings/test_create.py b/google/genai/tests/shared/tunings/test_create.py index b7b442eeb..cca485dec 100644 --- a/google/genai/tests/shared/tunings/test_create.py +++ b/google/genai/tests/shared/tunings/test_create.py @@ -43,6 +43,8 @@ globals_for_file=globals(), test_method='tunings.tune', test_table=test_table, + # Ignore the env var and always set the location to us-central1 + location='us-central1', ) pytest_plugins = ('pytest_asyncio',) diff --git a/google/genai/tests/shared/tunings/test_create_get_cancel.py b/google/genai/tests/shared/tunings/test_create_get_cancel.py index 7e27bb5c2..18e66fbd3 100644 --- a/google/genai/tests/shared/tunings/test_create_get_cancel.py +++ b/google/genai/tests/shared/tunings/test_create_get_cancel.py @@ -54,6 +54,8 @@ def create_get_cancel(client, parameters): globals_for_file=globals(), test_method="create_get_cancel", test_table=test_table, + # Ignore the env var and always set the location to us-central1 + location="us-central1", ) pytest_plugins = ("pytest_asyncio",)