Skip to content

Conversation

@howieleung
Copy link
Member

@howieleung howieleung commented Jan 4, 2026

Refractor code for Python SDK team to move sample test feature to dev tools including:

  • Moved test executor classes to sample_executor.py and later to be moved to dev tools
  • Moved other helper functions not going to dev tools to test_samples_helpers.py
  • Move LM validation from execute to a new function, validate_print_calls_by_llm
  • Restore sample_to_test argument for get_sample_paths func.

New stuff:

  • Readme
  • Make env_var_mapping to be optional
  • While you can run sample recording for the mandatory env vars, you can specific additional test to use optional env vars too
  • removed test only env var names. Test now uses the same env var used by samples but instead of using .env, use .test.env

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the sample testing infrastructure for the Azure AI Projects SDK. The main goal is to consolidate, simplify, and improve the framework for running and validating SDK samples as automated tests with recording/playback support.

Key Changes

  • Consolidated sample executor logic into a single sample_executor.py module (replacing sample_executor_helpers.py)
  • Introduced new features including additionalSampleTests decorator for testing samples with optional environment variables
  • Separated shared constants and helpers into test_samples_helpers.py for better modularity
  • Added comprehensive documentation in a new README.md explaining the testing framework

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
sdk/ai/azure-ai-projects/tests/samples/sample_executor.py New consolidated module containing all sample executor classes (SyncSampleExecutor, AsyncSampleExecutor), sample path discovery functions, and the additionalSampleTests decorator for parametrized test variants
sdk/ai/azure-ai-projects/tests/samples/test_samples_helpers.py New helper module extracting shared constants (agent_tools_instructions) and utility functions (get_sample_environment_variables_map)
sdk/ai/azure-ai-projects/tests/samples/test_samples.py Updated to import from new modules, added usage of additionalSampleTests decorator, and separated validation from execution
sdk/ai/azure-ai-projects/tests/samples/test_samples_async.py Updated to import from new modules and use the refactored async executor with separated validation
sdk/ai/azure-ai-projects/tests/samples/sample_executor_helpers.py Deleted file - functionality moved to sample_executor.py and test_samples_helpers.py
sdk/ai/azure-ai-projects/tests/samples/README.md New comprehensive documentation explaining the sample testing framework, with sync/async examples and usage patterns
sdk/ai/azure-ai-projects/assets.json Updated recording assets tag to reflect new test recordings

@howieleung howieleung force-pushed the howie/sample-recording-9 branch from 6dd77eb to 0d03d51 Compare January 4, 2026 06:43
- Changed environment variable names in test files to use a consistent naming convention, replacing "azure_ai_projects_tests_" prefix with a simplified version.
- Updated references in test cases to reflect the new environment variable names for model deployments, project endpoints, and connection IDs.
- Modified the sample executor to handle environment variable mapping more flexibly.
- Ensured all tests are aligned with the new naming conventions for better clarity and maintainability.
@howieleung howieleung force-pushed the howie/sample-recording-9 branch from 0d03d51 to 20deee8 Compare January 4, 2026 07:24
@howieleung howieleung changed the title Howie/sample recording 9 Test and sample recording Jan 5, 2026
@dargilco
Copy link
Member

dargilco commented Jan 5, 2026

Since we have .env.template, do we now also need .env.test.template?

@howieleung howieleung enabled auto-merge (squash) January 5, 2026 19:24
@howieleung howieleung merged commit 74a48aa into main Jan 5, 2026
20 checks passed
@howieleung howieleung deleted the howie/sample-recording-9 branch January 5, 2026 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants