File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2020
2121from __future__ import annotations
2222
23+ import importlib .util
2324import os
2425from pathlib import Path
2526import 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# =============================================================================
You can’t perform that action at this time.
0 commit comments