fix(sfm): an audit row can be finished once, from pending -- anything else raises
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
This commit is contained in:
1 parent
fb9b48f259
commit
ff0cce1cb2
3 files changed
+34
-3
No files matched your search
@@ -39,3 +39,26 @@ def test_db_audit_is_a_thin_sink(tmp_path):
|
||||
audit.finish(cid, outcome="failed", verified="mismatch", ack=None, error="unit reads idle")
|
||||
row = db.query_device_commands()[0]
|
||||
assert (row["outcome"], row["verified"], row["error"]) == ("failed", "mismatch", "unit reads idle")
|
||||
|
||||
|
||||
def test_finishing_an_unknown_id_raises_and_creates_nothing(tmp_path):
|
||||
import pytest
|
||||
db = SeismoDb(tmp_path / "s.db")
|
||||
with pytest.raises(ValueError, match="no-such-id"):
|
||||
db.finish_device_command("no-such-id", outcome="sent", verified="ok",
|
||||
ack=None, error=None)
|
||||
assert db.query_device_commands() == []
|
||||
|
||||
|
||||
def test_a_second_finish_raises_and_keeps_the_first_result(tmp_path):
|
||||
import pytest
|
||||
db = SeismoDb(tmp_path / "s.db")
|
||||
cid = db.begin_device_command(**ROW)
|
||||
db.finish_device_command(cid, outcome="failed", verified="mismatch",
|
||||
ack={"subs": ["0x69"]}, error="unit reads idle")
|
||||
with pytest.raises(ValueError, match=cid):
|
||||
db.finish_device_command(cid, outcome="sent", verified="ok",
|
||||
ack={"other": 1}, error=None)
|
||||
row = db.query_device_commands()[0]
|
||||
assert (row["outcome"], row["verified"], row["ack"], row["error"]) == \
|
||||
("failed", "mismatch", {"subs": ["0x69"]}, "unit reads idle")
|
||||
Reference in new issue
Block a user