Run all tests with the Interactions API.
()
| 308 | |
| 309 | |
| 310 | async def run_all_tests(): |
| 311 | """Run all tests with the Interactions API.""" |
| 312 | print("\n" + "#" * 70) |
| 313 | print("# Running tests with Interactions API") |
| 314 | print("#" * 70) |
| 315 | |
| 316 | # Check if interactions API is available |
| 317 | if not check_interactions_api_available(): |
| 318 | print("\nERROR: Interactions API is not available in the current SDK.") |
| 319 | print("The interactions API requires a SDK version with this feature.") |
| 320 | print("To use the interactions API, ensure you have the SDK with") |
| 321 | print("interactions support installed (e.g., from private-python-genai).") |
| 322 | return False |
| 323 | |
| 324 | test_agent = root_agent |
| 325 | |
| 326 | runner = InMemoryRunner( |
| 327 | agent=test_agent, |
| 328 | app_name=APP_NAME, |
| 329 | ) |
| 330 | |
| 331 | # Create a new session |
| 332 | session = await runner.session_service.create_session( |
| 333 | user_id=USER_ID, |
| 334 | app_name=APP_NAME, |
| 335 | ) |
| 336 | print(f"\nSession created: {session.id}") |
| 337 | |
| 338 | try: |
| 339 | # Run all tests |
| 340 | await test_basic_text_generation(runner, session.id) |
| 341 | await test_function_calling(runner, session.id) |
| 342 | await test_multi_turn_conversation(runner, session.id) |
| 343 | await test_google_search_tool(runner, session.id) |
| 344 | await test_custom_function_tool(runner, session.id) |
| 345 | await test_pdf_summarization(runner, session.id) |
| 346 | |
| 347 | print("\n" + "=" * 60) |
| 348 | print("ALL TESTS PASSED (Interactions API)") |
| 349 | print("=" * 60) |
| 350 | return True |
| 351 | |
| 352 | except AssertionError as e: |
| 353 | print(f"\nTEST FAILED: {e}") |
| 354 | return False |
| 355 | except Exception as e: |
| 356 | print(f"\nERROR: {e}") |
| 357 | import traceback |
| 358 | |
| 359 | traceback.print_exc() |
| 360 | return False |
| 361 | |
| 362 | |
| 363 | async def interactive_mode(): |
no test coverage detected