Review fix: race tests read via the DAO, not raw SQL probes

The children/admin_users leak guard forbids children SQL outside the
DAO and its sanctioned test files; the two gated concurrency tests
probed the children table raw. They now assert via ChildrenDao.get.
Suite: 850 passed.
This commit is contained in:
Joshua King
2026-09-15 14:14:56 -04:00
parent 5578507ce8
commit 09363a57cf
+9 -11
View File
@@ -14,7 +14,7 @@ from custom_components.nestquest.children import (
list_children, list_children,
set_child_active, set_child_active,
) )
from custom_components.nestquest.dao_children import ChildRecord from custom_components.nestquest.dao_children import ChildRecord, ChildrenDao
from custom_components.nestquest.db import NestQuestDatabase from custom_components.nestquest.db import NestQuestDatabase
from custom_components.nestquest.migrations import apply_migrations from custom_components.nestquest.migrations import apply_migrations
@@ -448,12 +448,11 @@ def test_edit_child_concurrent_opposite_edits_return_own_values(
assert record_a.sort_order == 1 assert record_a.sort_order == 1
assert record_b.colour == "#BBBBBB" assert record_b.colour == "#BBBBBB"
assert record_b.sort_order == 2 assert record_b.sort_order == 2
# B landed last: the stored row is B's. # B landed last: the stored row is B's (read via the DAO —
row = await database.fetch_one( # the children leak guard forbids raw probes here).
"SELECT colour, sort_order FROM children WHERE id = ?", stored = await ChildrenDao(database).get(child.id)
(child.id,), assert stored is not None
) assert (stored.colour, stored.sort_order) == ("#BBBBBB", 2)
assert row == ("#BBBBBB", 2)
finally: finally:
await database.close() await database.close()
@@ -494,10 +493,9 @@ def test_set_child_active_concurrent_opposite_transitions_return_own(
assert record_a.is_active is False assert record_a.is_active is False
assert record_b.is_active is True assert record_b.is_active is True
row = await database.fetch_one( stored = await ChildrenDao(database).get(child.id)
"SELECT is_active FROM children WHERE id = ?", (child.id,) assert stored is not None
) assert stored.is_active is True
assert row == (1,)
finally: finally:
await database.close() await database.close()