Skip to content

Commit 77356d8

Browse files
wyf7107copybara-github
authored andcommitted
No public description
Co-authored-by: Yifan Wang <wanyif@google.com> PiperOrigin-RevId: 927466558
1 parent e7eb5fe commit 77356d8

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

tests/unittests/test_optional_dependencies.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
from __future__ import annotations
2222

23+
import importlib.util
2324
import os
2425
from pathlib import Path
2526
import subprocess
@@ -167,6 +168,24 @@ def test_vertex_ai_session_service_fails_on_creation():
167168
assert "google-cloud-aiplatform" in str(exc_info.value)
168169

169170

171+
def test_vertexai_dependency_shim_raises_clear_importerror():
172+
"""Verify that the Vertex AI dependency shim points users to the dependency."""
173+
with mock.patch.dict("sys.modules", {"google.cloud.aiplatform": None}):
174+
module_path = _REPO_ROOT / "dependencies_internal/vertexai.py"
175+
spec = importlib.util.spec_from_file_location(
176+
"_test_google_adk_dependencies_vertexai", module_path
177+
)
178+
assert spec is not None
179+
assert spec.loader is not None
180+
module = importlib.util.module_from_spec(spec)
181+
182+
with pytest.raises(ImportError) as exc_info:
183+
spec.loader.exec_module(module)
184+
185+
message = str(exc_info.value)
186+
assert "//third_party/py/google/cloud/aiplatform" in message
187+
188+
170189
# =============================================================================
171190
# Approach 2: High-Fidelity Integration Tests (Clean Venv, Skipped by Default)
172191
# =============================================================================

0 commit comments

Comments
 (0)