Files
genai-toolbox/docs/en/getting-started/quickstart/python/quickstart_test.py
Anubhav Dhawan 923479034f docs: Improve and simplify ADK Python Quickstart (#1962)
## Description
This PR updates the ADK portion of the Python local quickstart to align
with the latest ADK getting started guide. The previous instructions
involved a complex, boilerplate-heavy script that was not the
recommended approach and made it difficult to focus on the Toolbox
integration.

### Improvements

* The guide now uses the `adk` CLI (e.g., `adk create`, `adk web`),
which is the standard and more intuitive way to work with ADK projects.
* The agent script is now much simpler and more focused, removing a
significant amount of ADK-specific boilerplate. This makes it easier for
users to see how Toolbox is integrated.
* The steps are clearer, and we've added links to more in-depth ADK
documentation for running agents locally and deploying them to the
cloud.

### Before
<img width="1820" height="1852" alt="image"
src="https://github.com/user-attachments/assets/cecb8a4d-cccb-4488-8fca-df5f86c153e9"
/>

### After
<img width="1800" height="1830" alt="image"
src="https://github.com/user-attachments/assets/9200fb51-548e-4188-b42f-1850a47d7349"
/>

### Before
<img width="1778" height="278" alt="image"
src="https://github.com/user-attachments/assets/beb32070-5ef4-4bfb-b8ce-04268da4aa90"
/>

### After
<img width="1822" height="852" alt="image"
src="https://github.com/user-attachments/assets/5e725058-7bae-4e44-9d69-25c46d88005a"
/>

These changes provide a much smoother and more straightforward
onboarding experience for developers using ADK with Toolbox.

🛠️ Addresses https://github.com/googleapis/genai-toolbox/issues/1705
Fixes https://github.com/googleapis/mcp-toolbox-sdk-python/issues/370
2025-11-26 18:41:36 +05:30

72 lines
2.5 KiB
Python
Executable File

# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import pytest
from pathlib import Path
import asyncio
import sys
import importlib.util
ORCH_NAME = os.environ.get("ORCH_NAME")
module_path = f"python.{ORCH_NAME}.quickstart"
quickstart = importlib.import_module(module_path)
@pytest.fixture(scope="module")
def golden_keywords():
"""Loads expected keywords from the golden.txt file."""
golden_file_path = Path("../golden.txt")
if not golden_file_path.exists():
pytest.fail(f"Golden file not found: {golden_file_path}")
try:
with open(golden_file_path, 'r') as f:
return [line.strip() for line in f.readlines() if line.strip()]
except Exception as e:
pytest.fail(f"Could not read golden.txt: {e}")
# --- Execution Tests ---
class TestExecution:
"""Test framework execution and output validation."""
@pytest.fixture(scope="function")
def script_output(self, capsys):
"""Run the quickstart function and return its output."""
# TODO: Add better validation for ADK once we have a way to capture its
# output.
if ORCH_NAME == "adk":
return quickstart.app.root_agent.name
else:
asyncio.run(quickstart.main())
return capsys.readouterr()
def test_script_runs_without_errors(self, script_output):
"""Test that the script runs and produces no stderr."""
if ORCH_NAME == "adk":
return
assert script_output.err == "", f"Script produced stderr: {script_output.err}"
def test_keywords_in_output(self, script_output, golden_keywords):
"""Test that expected keywords are present in the script's output."""
if ORCH_NAME == "adk":
assert script_output == "root_agent"
return
output = script_output.out
missing_keywords = [kw for kw in golden_keywords if kw not in output]
assert not missing_keywords, f"Missing keywords in output: {missing_keywords}"