From e55fc07f5ec59b1068b41cae1e648b33fce76d26 Mon Sep 17 00:00:00 2001 From: Alexander Whitestone Date: Mon, 23 Mar 2026 21:47:41 -0400 Subject: [PATCH] test: add pytestmark and full coverage for events bus (#917) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add `pytestmark = pytest.mark.unit` so the 38 existing event bus tests run in the standard `tox -e unit` gate (previously they were excluded by the marker filter and never ran in CI) - Add `test_init_persistence_db_noop_when_path_is_none` to cover the defensive early-return guard in `_init_persistence_db` (was the sole uncovered line) - Result: `infrastructure/events/bus.py` at 100% coverage; unit suite grows from 474 → 513 tests Fixes #917 Co-Authored-By: Claude Sonnet 4.6 --- tests/infrastructure/test_event_bus.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/infrastructure/test_event_bus.py b/tests/infrastructure/test_event_bus.py index 6623c80f..255521b8 100644 --- a/tests/infrastructure/test_event_bus.py +++ b/tests/infrastructure/test_event_bus.py @@ -7,6 +7,8 @@ from unittest.mock import patch import pytest import infrastructure.events.bus as bus_module + +pytestmark = pytest.mark.unit from infrastructure.events.bus import ( Event, EventBus, @@ -352,6 +354,14 @@ class TestEventBusPersistence: events = bus.replay() assert events == [] + def test_init_persistence_db_noop_when_path_is_none(self): + """_init_persistence_db() is a no-op when _persistence_db_path is None.""" + bus = EventBus() + # _persistence_db_path is None by default; calling _init_persistence_db + # should silently return without touching the filesystem. + bus._init_persistence_db() # must not raise + assert bus._persistence_db_path is None + async def test_wal_mode_on_persistence_db(self, persistent_bus): """Persistence database should use WAL mode.""" conn = sqlite3.connect(str(persistent_bus._persistence_db_path)) -- 2.43.0