|
| 1 | +# Copyright 2025 Google LLC |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | +# |
| 15 | +# pylint: disable=protected-access,bad-continuation,missing-function-docstring |
| 16 | + |
| 17 | +import datetime |
| 18 | + |
| 19 | +from tests.unit.vertexai.genai.replays import pytest_helper |
| 20 | +from vertexai._genai import types |
| 21 | + |
| 22 | + |
| 23 | +def test_list_session_events(client): |
| 24 | + agent_engine = client.agent_engines.create() |
| 25 | + operation = client.agent_engines.create_session( |
| 26 | + name=agent_engine.api_resource.name, |
| 27 | + user_id="test-user-123", |
| 28 | + ) |
| 29 | + session = operation.response |
| 30 | + assert not list( |
| 31 | + client.agent_engines.list_session_events( |
| 32 | + name=session.name, |
| 33 | + ) |
| 34 | + ) |
| 35 | + client.agent_engines.append_session_event( |
| 36 | + name=session.name, |
| 37 | + author="test-user-123", |
| 38 | + invocation_id="test-invocation-id", |
| 39 | + timestamp=datetime.datetime.fromtimestamp(1234567890, tz=datetime.timezone.utc), |
| 40 | + ) |
| 41 | + session_event_list = client.agent_engines.list_session_events( |
| 42 | + name=session.name, |
| 43 | + ) |
| 44 | + assert len(session_event_list) == 1 |
| 45 | + assert isinstance(session_event_list[0], types.SessionEvent) |
| 46 | + |
| 47 | + |
| 48 | +pytestmark = pytest_helper.setup( |
| 49 | + file=__file__, |
| 50 | + globals_for_file=globals(), |
| 51 | + test_method="agent_engines.list_session_events", |
| 52 | +) |
0 commit comments