mirror of
https://github.com/EvolutionAPI/adk-python.git
synced 2025-12-19 03:42:22 -06:00
fix(tests): use mock GCS client in artifact service tests to avoid real credentials
Copybara import of the project: -- ade1d98e030a966183f56cb5c9c1b04cf51f5337 by Thiago Neves <thiagohneves@gmail.com>: fix(tests): use mock GCS client in artifact service tests to avoid real credentials -- becd2925feebf60196129b029a0ab8d490f7b19e by Thiago Neves <thiagohneves@gmail.com>: test(agents): add unit tests for live_request_queue, readonly_context, and run_config COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/641 from thiagoneves:feature/increase-test-coverage 0f7a9fc55d97902e190a394f099324fbeb1541af PiperOrigin-RevId: 756798390
This commit is contained in:
committed by
Copybara-Service
parent
dc5c23c675
commit
ac97fc638f
33
tests/unittests/agents/test_readonly_context.py
Normal file
33
tests/unittests/agents/test_readonly_context.py
Normal file
@@ -0,0 +1,33 @@
|
||||
import pytest
|
||||
from unittest.mock import MagicMock
|
||||
from types import MappingProxyType
|
||||
from google.adk.agents.readonly_context import ReadonlyContext
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_invocation_context():
|
||||
mock_context = MagicMock()
|
||||
mock_context.invocation_id = "test-invocation-id"
|
||||
mock_context.agent.name = "test-agent-name"
|
||||
mock_context.session.state = {"key1": "value1", "key2": "value2"}
|
||||
|
||||
return mock_context
|
||||
|
||||
|
||||
def test_invocation_id(mock_invocation_context):
|
||||
readonly_context = ReadonlyContext(mock_invocation_context)
|
||||
assert readonly_context.invocation_id == "test-invocation-id"
|
||||
|
||||
|
||||
def test_agent_name(mock_invocation_context):
|
||||
readonly_context = ReadonlyContext(mock_invocation_context)
|
||||
assert readonly_context.agent_name == "test-agent-name"
|
||||
|
||||
|
||||
def test_state_content(mock_invocation_context):
|
||||
readonly_context = ReadonlyContext(mock_invocation_context)
|
||||
state = readonly_context.state
|
||||
|
||||
assert isinstance(state, MappingProxyType)
|
||||
assert state["key1"] == "value1"
|
||||
assert state["key2"] == "value2"
|
||||
Reference in New Issue
Block a user