Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion google/genai/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand All @@ -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)
Expand Down Expand Up @@ -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(
Expand Down
7 changes: 4 additions & 3 deletions google/genai/tests/pytest_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand Down Expand Up @@ -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),
],
)

Expand Down
2 changes: 1 addition & 1 deletion google/genai/tests/shared/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 1 addition & 3 deletions google/genai/tests/shared/batches/test_create_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
),
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def create_get_cancel(client, parameters):
}]
}],
),
exception_if_vertex="Exactly one of ",
exception_if_vertex="only supported in Gemini Developer",
),
]

Expand Down
2 changes: 1 addition & 1 deletion google/genai/tests/shared/files/test_upload_get_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
),
]

Expand Down
2 changes: 1 addition & 1 deletion google/genai/tests/shared/models/test_embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions google/genai/tests/shared/tunings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
2 changes: 2 additions & 0 deletions google/genai/tests/shared/tunings/test_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',)
2 changes: 2 additions & 0 deletions google/genai/tests/shared/tunings/test_create_get_cancel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",)
Loading