refactor: no functions inside functions in the worker and the tests
Merged
HA
6d ago+486+486+012345678901234567890123456789-635-635-012345678901234567890123456789
Summary
Fixes #
Changes
Type of Change
- Bug fix (non-breaking change that fixes an issue)
- New feature (non-breaking change that adds functionality)
- Breaking change (fix or feature that would cause existing functionality to change)
- Documentation update
- Refactoring (no functional changes)
- CI/CD or tooling changes
Test Plan
- Backend unit tests pass (
cd backend && uv run pytest tests/unit) - Frontend unit tests pass (
cd frontend && npm run test) - Backend E2E tests pass (
docker compose exec -T backend sh -c 'uv sync --group test --no-dev --frozen --no-install-project --no-build && pytest tests/e2e') - Frontend E2E tests pass (
cd frontend && npm run test:e2e) - API spec and client regenerated if routes or schemas changed (
./deploy.sh openapi, then./deploy.sh types), never edited by hand - Manual testing performed
Manual test steps:
Checklist
- My code follows the project's style guidelines
- I have run
pre-commit run --all-filesand all checks pass - I have added tests that prove my fix/feature works
- I have updated documentation if needed
- My changes don't introduce new warnings
Screenshots (if applicable)
Summary by cubic
Refactors the worker and its tests to eliminate nested functions, moving the pod watch error handling and 410 cursor reset into PodMonitor.watch_cycle. The worker now calls a module-level start_jobs and binds scheduler.shutdown and container.close directly to the FastStream hooks, so it no longer reaches into the monitor's private cursor.
- Test fakes and callbacks defined inside test functions became module-level classes, bound methods, and
AsyncMock/MagicMockconfigurations; Dishka mocks are now wired throughfrom_context. - Removed
hypothesisandtests/load/strategies.py, since the strategy was only used to generate random JSON bodies; the load tool's clients now run inasync withblocks. - Building a
PodMonitorin tests no longer creates a real Kubernetes watch client, so the monitor tests pass with warnings as errors.