From a71d9ea9a17ea1a7ca1bebde3ed960a6868290de Mon Sep 17 00:00:00 2001 From: Shangjie Chen Date: Thu, 15 May 2025 14:56:03 -0700 Subject: [PATCH] fix: fix broken tests. PiperOrigin-RevId: 759312577 --- .../sessions/test_vertex_ai_session_service.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/unittests/sessions/test_vertex_ai_session_service.py b/tests/unittests/sessions/test_vertex_ai_session_service.py index 592bce2..0722662 100644 --- a/tests/unittests/sessions/test_vertex_ai_session_service.py +++ b/tests/unittests/sessions/test_vertex_ai_session_service.py @@ -124,6 +124,20 @@ class MockApiClient: this.session_dict: dict[str, Any] = {} this.event_dict: dict[str, list[Any]] = {} + def request(self, http_method: str, path: str, request_dict: dict[str, Any]): + """Mocks the API Client request method.""" + if http_method == 'GET': + if re.match(SESSIONS_REGEX, path): + match = re.match(SESSIONS_REGEX, path) + return { + 'sessions': [ + session + for session in self.session_dict.values() + if session['userId'] == match.group(2) + ], + } + raise ValueError(f'Unsupported sync path: {path}') + async def async_request( self, http_method: str, path: str, request_dict: dict[str, Any] ):