Repository navigation
refactor: no functions inside functions in the worker and the tests - #382
Merged
Merged
Conversation
HardMax71
added this pull request to stack #379
October 13, 2026 22:54
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Codecov Report❌ Patch coverage is
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
app/worker.py nested run, start, watch_pods and stop_scheduler inside main. main and run are module-level now, start_jobs prepares the cluster and returns the started scheduler, and FastStream gets bound methods as hooks: scheduler.shutdown before the broker stops, container.close after. The watch cycle's error handling moved into PodMonitor.watch_cycle, so the worker no longer reaches into the monitor's private cursor, and it has tests now. In the tests, fakes and callbacks defined inside test functions became module-level classes, plain AsyncMock and MagicMock configurations, bound methods or named functions: the streaming ASGI transport and the middleware harnesses keep their state in small channel classes, routes and subscribers are registered explicitly, call order comes from attach_mock, the JWT cases are data instead of lambdas, and Dishka gets mocks through from_context. Building a PodMonitor no longer leaks a real Kubernetes watch client, so the monitor tests pass with warnings as errors, and they carry no type: ignore. The load tool's clients live in async with blocks, and its Hypothesis strategy, which only ran through .example(), is gone along with the dependency.
HardMax71
force-pushed
the
refactor/no-nested-functions
branch
from
October 13, 2026 23:27
c298c8f to
5fb6f3c
Compare
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.



Summary
Fixes #
Changes
Type of Change
Test Plan
cd backend && uv run pytest tests/unit)cd frontend && npm run test)docker compose exec -T backend sh -c 'uv sync --group test --no-dev --frozen --no-install-project --no-build && pytest tests/e2e')cd frontend && npm run test:e2e)./deploy.sh openapi, then./deploy.sh types), never edited by handManual test steps:
Checklist
pre-commit run --all-filesand all checks passScreenshots (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-levelstart_jobsand bindsscheduler.shutdownandcontainer.closedirectly to the FastStream hooks, so it no longer reaches into the monitor's private cursor.AsyncMock/MagicMockconfigurations; Dishka mocks are now wired throughfrom_context.hypothesisandtests/load/strategies.py, since the strategy was only used to generate random JSON bodies; the load tool's clients now run inasync withblocks.PodMonitorin tests no longer creates a real Kubernetes watch client, so the monitor tests pass with warnings as errors.Written for commit 5fb6f3c. Summary will update on new commits.