mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
chore: Add X-Goog-API-Client header to GDA API requests
PiperOrigin-RevId: 869372484
This commit is contained in:
committed by
Copybara-Service
parent
c6b1c74321
commit
d85932faa3
@@ -89,6 +89,12 @@ def test_ask_data_insights_success(mock_get_stream):
|
||||
assert result["response"] == "Final formatted string from stream"
|
||||
mock_get_stream.assert_called_once()
|
||||
|
||||
# Verify that the correct headers and client ID were passed to _get_stream
|
||||
args, _ = mock_get_stream.call_args
|
||||
headers = args[2]
|
||||
assert headers["X-Goog-API-Client"] == "GOOGLE_ADK"
|
||||
assert headers["Authorization"] == "Bearer fake-token"
|
||||
|
||||
|
||||
@mock.patch.object(data_insights_tool, "_get_stream")
|
||||
def test_ask_data_insights_handles_exception(mock_get_stream):
|
||||
|
||||
@@ -196,3 +196,16 @@ def test_get_stream_from_file(mock_post, case_file_path):
|
||||
|
||||
# 6. Assert that the final list of dicts matches the expected output
|
||||
assert result == expected_final_list
|
||||
|
||||
|
||||
def test_get_http_headers_includes_client_id():
|
||||
"""Tests _get_http_headers includes the correct GDA client ID."""
|
||||
mock_creds = mock.Mock()
|
||||
mock_creds.token = "fake-token"
|
||||
|
||||
# pylint: disable=protected-access
|
||||
headers = data_agent_tool._get_http_headers(mock_creds)
|
||||
|
||||
assert headers["X-Goog-API-Client"] == "GOOGLE_ADK"
|
||||
assert headers["Content-Type"] == "application/json"
|
||||
assert headers["Authorization"] == "Bearer fake-token"
|
||||
|
||||
Reference in New Issue
Block a user