diff --git a/tests/test_database_audit.py b/tests/test_database_audit.py new file mode 100644 index 0000000..92ac210 --- /dev/null +++ b/tests/test_database_audit.py @@ -0,0 +1,26 @@ +"""Tests for MotionDatabase.append_audit_event — no filesystem side effects on audit path.""" + + +def test_append_audit_event_returns_true(mem_db): + """append_audit_event should succeed (DB or ledger fallback) and return True.""" + ok = mem_db.append_audit_event( + actor_id=None, + action="test_action", + target_type="unit", + target_id="u1", + metadata={"k": 1}, + ) + assert ok is True + + +def test_append_audit_event_does_not_raise_on_bad_db(mem_db): + """Even if DB insert fails, the method falls back and doesn't raise.""" + ok = mem_db.append_audit_event( + actor_id=None, + action="another_action", + target_type="motion", + target_id=None, + metadata={}, + ) + # Returns True or False, but must not raise + assert isinstance(ok, bool)