refactor(tests): tidy the occupancy test-reset seed helpers #264
Labels
No labels
blocked
bug
enhancement
high-priority
low-priority
needs-info
needs-triage
ready-for-agent
ready-for-human
referenced
research
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gabogg/hikcentral#264
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
P3 follow-up from PR #233 review pass 2 (standards axis).
Finding
occupancy_repository.py~478-479) hardcodes thetrust_*literals (10, 0.35, 0.80, 1.30, 5000, 1000), which also appear in theALTERdefaults (database.py~243) and in theget_config_syncfallback. It sets only some of the trust and statistics columns;trust_negative_net_limit,trust_spike_*andstatistics_min_comparison_coveragefall back to column defaults. List all of them, or rely on column defaults for all of them.seed_default_occupancy_config(~3363) andreset_config_to_defaults_sync(~501) only forward toseed_default_config. The production repository also carries a destructiveINSERT OR REPLACEreset that only tests call. Consider moving the reset into the test helper module.reset_daily_schedules_sync(conn=...)(~887) reads its return value through a new connection before the caller commits, so under WAL it returns the old schedule. Reuseconn.DEFAULT_DAILY_SCHEDULEis a positional 5-tuple indexed withday[0], and its hours are bare strings even thoughOpeningHoursexists.PYTEST_SHUFFLE_SEED(tests/conftest.py~72-84) is undocumented, importsrandominside the function, and overlaps #217/#218. Document it in the test docs, or fold it into the #218 test-loop work.Acceptance Criteria
PYTEST_SHUFFLE_SEEDis documented, or owned by #218.Adding scope from PR #233 review pass 3 (P3).
tests/occupancy_reset.py:11checks only thatoccupancy_configexists before deleting from six other tables. A test that points the database at a partly initialized schema would crash in teardown. Guard each table, or check the whole set.