End-to-End Python Hook Tests
Part of #7435 — Multi-Language Hook Support
User Story
As a developer maintaining the hook system, I want comprehensive end-to-end tests that verify the full Python hook lifecycle so regressions are caught automatically.
Solution Approach
Test scenario 1 — Happy path:
- Create test project with:
azure.yaml with preprovision Python hook
scripts/setup.py that reads an env var and writes it to a marker file
scripts/requirements.txt with a simple dependency
- Verify:
- Hook detected as Python language hook
- Virtual environment created (
.venv exists)
- Dependencies installed
- Script executes successfully
- Environment variables available to script
- Exit code 0
Test scenario 2 — Auto-detect vs explicit:
- Test with
run: scripts/setup.py (auto-detect from .py)
- Test with
run: scripts/setup + language: python (explicit)
- Both should execute identically
Test scenario 3 — Error cases:
- Missing Python runtime → clear error with install URL
- Missing script file → clear error
- Script exits non-zero → error propagated
continueOnError: true + failing script → no error, continues
Test scenario 4 — Service-level hooks:
- Python hook defined under a service, not project root
- Verify project discovery scoped to service directory
Location: Follow existing patterns in test/functional/testdata/samples/ for fixtures, test/functional/ or pkg/ext/ for test files.
Files: test/functional/ or pkg/ext/hooks_runner_test.go (NEW/MODIFY), test fixtures
Acceptance Criteria
References
End-to-End Python Hook Tests
Part of #7435 — Multi-Language Hook Support
User Story
As a developer maintaining the hook system, I want comprehensive end-to-end tests that verify the full Python hook lifecycle so regressions are caught automatically.
Solution Approach
Test scenario 1 — Happy path:
azure.yamlwithpreprovisionPython hookscripts/setup.pythat reads an env var and writes it to a marker filescripts/requirements.txtwith a simple dependency.venvexists)Test scenario 2 — Auto-detect vs explicit:
run: scripts/setup.py(auto-detect from.py)run: scripts/setup+language: python(explicit)Test scenario 3 — Error cases:
continueOnError: true+ failing script → no error, continuesTest scenario 4 — Service-level hooks:
Location: Follow existing patterns in
test/functional/testdata/samples/for fixtures,test/functional/orpkg/ext/for test files.Files:
test/functional/orpkg/ext/hooks_runner_test.go(NEW/MODIFY), test fixturesAcceptance Criteria
language:fieldReferences