Enhance UI rendering and add unit tests for simulation functionality

- Updated the `_render` function in `ui.py` to correctly pass the request object to `TemplateResponse`.
- Initialized `upcoming_maintenance` as a typed list in `_load_dashboard` for better type safety.
- Added new unit tests in `test_simulation.py` to cover triangular sampling and uniform distribution defaults.
- Implemented a test to ensure that running the simulation without parameters returns an empty result.
- Created a parameterized test in `test_ui_routes.py` to verify that additional UI routes render the correct templates and context.
This commit is contained in:
2025-10-21 09:26:39 +02:00
parent 9114b584c2
commit 139ae04538
6 changed files with 2319 additions and 8 deletions

View File

@@ -113,12 +113,11 @@ pytest
- The fixture now polls `[http://localhost:8001](http://localhost:8001)` until it responds (up to ~30s), ensuring the uvicorn subprocess is ready before Playwright starts navigation, then preloads `/` and waits for a `networkidle` state so sidebar navigation and global assets are ready for each test.
- Latest run (`pytest tests/e2e/` on 2025-10-21) passes end-to-end smoke and form coverage after aligning form selectors, titles, and the live server startup behaviour.
### Coverage Snapshot (2025-10-20)
### Coverage Snapshot (2025-10-21)
- `pytest --cov=. --cov-report=term-missing` reports **95%** overall coverage across the project.
- Lower coverage hotspots to target next: `services/simulation.py` (79%), `middleware/validation.py` (78%), `routes/ui.py` (82%), and several API routers around lines 12-22 that create database sessions only.
- Deprecation cleanup migrated routes to Pydantic v2 patterns (`model_config = ConfigDict(...)`, `model_dump()`) and updated SQLAlchemy's `declarative_base`; reran `pytest` to confirm the suite passes without warnings.
- Coverage for route-heavy modules is primarily limited by error paths (e.g., bad request branches) that still need explicit tests.
- `pytest --cov=. --cov-report=term-missing` reports **91%** overall coverage.
- Recent additions pushed `routes/ui.py` and `services/simulation.py` to 100%; remaining gaps are concentrated in `config/database.py`, several `models/*.py` loaders, and `services/reporting.py` (95%).
- Playwright specs under `tests/e2e/` are excluded from the coverage run to keep browser automation optional; their files show as uncovered because they are not executed in the `pytest --cov` workflow.
## Database Objects