feat(python): add smoke test generation for production environment testing #11418
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Refs: Requested by @davidkonigsberg
Adds a new smoke test generation feature to the Python SDK generator. When enabled, the SDK generates tests in
tests/smoke/that can be run against a production environment to verify that API examples work correctly.Link to Devin run: https://app.devin.ai/sessions/e9f4af0bad3045c0b0542ca02ac4ca06
Changes Made
ValidationFilterConfigclass for filtering which examples get specific validation typesSmokeTestConfigclass with layered validation configuration:generate_smoke_tests- Enable/disable smoke test generationinclude_examples/exclude_examples- Filter which examples to generate tests forstructural_validation- Filter config for type/structure validation (default: all examples)strict_validation- Filter config for exact value matching (default: none)smoke_test_configoption toSDKCustomConfigSmokeTestFactoryclass that generates pytest tests intests/smoke/directorysmoke_test_utilities.pywithvalidate_smoke_test_response(structural) andvalidate_strict_response(exact match) functionssdk_generator.pyseed/python-sdk/examples/smoke-tests/demonstrating the featureUsage:
Validation modes:
Environment variables:
SMOKE_TEST_BASE_URL- Production API base URLSMOKE_TEST_<PARAM>- Auth tokens and other client parameters (string types only)Updates Since Last Revision
generate_smoke_testsflag insidesmoke_test_config(previously was a separate top-level config option)@fern-api/ir-utilsTypeScript error)Testing
pnpm run checkpasses)Human Review Checklist
boolvsintcorrectly (Python'sboolis a subclass ofint).dict()which is deprecated in v2 - should use.model_dump())_normalize_valuein strict validation handles all edge cases (datetime, UUID, nested Pydantic models)"no_validate") - verify this is acceptableseed/python-sdk/examples/smoke-tests/to verify output looks correct