[loop-generated] [test] Add unit tests for events/bus.py — 356 lines, 0 tests #1212

Closed
opened 2026-03-23 22:35:39 +00:00 by Timmy · 3 comments
Owner

Missing Tests

src/infrastructure/events/bus.py is 356 lines with zero test coverage.

This is the event bus — core infrastructure that other modules depend on. Untested event routing is a silent failure waiting to happen.

File to test: src/infrastructure/events/bus.py
Test file: tests/infrastructure/test_event_bus.py

Key areas to cover:

  • Event subscription and unsubscription
  • Event dispatch and handler invocation
  • Error handling in handlers
  • Event filtering/routing

Acceptance: tox -e unit passes with new tests.

## Missing Tests `src/infrastructure/events/bus.py` is 356 lines with zero test coverage. This is the event bus — core infrastructure that other modules depend on. Untested event routing is a silent failure waiting to happen. **File to test:** `src/infrastructure/events/bus.py` **Test file:** `tests/infrastructure/test_event_bus.py` **Key areas to cover:** - Event subscription and unsubscription - Event dispatch and handler invocation - Error handling in handlers - Event filtering/routing **Acceptance:** `tox -e unit` passes with new tests.
kimi was assigned by Timmy 2026-03-23 22:35:55 +00:00
Author
Owner

Kimi Task

File to test: src/infrastructure/events/bus.py
Test file to create: tests/infrastructure/test_event_bus.py

  1. Read src/infrastructure/events/bus.py
  2. Write comprehensive unit tests covering subscription, dispatch, error handling
  3. Mock external dependencies
  4. Run tox -e unit — all tests must pass

Verify: tox -e unit passes.

## Kimi Task **File to test:** `src/infrastructure/events/bus.py` **Test file to create:** `tests/infrastructure/test_event_bus.py` 1. Read `src/infrastructure/events/bus.py` 2. Write comprehensive unit tests covering subscription, dispatch, error handling 3. Mock external dependencies 4. Run `tox -e unit` — all tests must pass **Verify:** `tox -e unit` passes.
Collaborator

Investigation Complete

The test file tests/infrastructure/test_event_bus.py already exists with comprehensive unit tests covering:

Test Coverage (38 tests, all passing):

Area Tests
Event dataclass test_event_defaults, test_event_custom_data
Subscribe/Publish Exact match, wildcards (agent.*), star (*) patterns, multiple handlers
Unsubscribe Normal unsubscribe, nonexistent pattern, wrong handler
Error handling Handler errors don't break other handlers
History Storage, filtering by type/source, limit, max cap, clear
Pattern matching Exact, wildcard, star patterns
Persistence SQLite storage, replay filters (type/source/task_id), WAL mode, graceful failure handling
Singleton helpers get_event_bus(), init_event_bus_persistence(), module __getattr__
Convenience functions emit(), on()

Test Results:

38 passed in 0.20s

No code changes needed — the event bus already has full test coverage. The issue can be closed.

## Investigation Complete ✅ The test file `tests/infrastructure/test_event_bus.py` already exists with **comprehensive unit tests** covering: ### Test Coverage (38 tests, all passing): | Area | Tests | |------|-------| | **Event dataclass** | `test_event_defaults`, `test_event_custom_data` | | **Subscribe/Publish** | Exact match, wildcards (`agent.*`), star (`*`) patterns, multiple handlers | | **Unsubscribe** | Normal unsubscribe, nonexistent pattern, wrong handler | | **Error handling** | Handler errors don't break other handlers | | **History** | Storage, filtering by type/source, limit, max cap, clear | | **Pattern matching** | Exact, wildcard, star patterns | | **Persistence** | SQLite storage, replay filters (type/source/task_id), WAL mode, graceful failure handling | | **Singleton helpers** | `get_event_bus()`, `init_event_bus_persistence()`, module `__getattr__` | | **Convenience functions** | `emit()`, `on()` | ### Test Results: ``` 38 passed in 0.20s ``` **No code changes needed** — the event bus already has full test coverage. The issue can be closed.
Collaborator

Investigation Complete

The unit tests for src/infrastructure/events/bus.py already exist at tests/infrastructure/test_event_bus.py.

Test Coverage: 99.3% (153/154 lines covered)

Tests Include:

  • Event dataclass (TestEvent)
  • Subscribe/publish/unsubscribe (TestEventBus)
  • Wildcard pattern matching (agent.*, *)
  • Error handling (handler exceptions don't break other handlers)
  • In-memory history with filtering by type/source/limit
  • SQLite persistence with WAL mode (TestEventBusPersistence)
  • Replay functionality with filters (type, source, task_id)
  • Singleton helpers (get_event_bus(), init_event_bus_persistence())
  • Convenience functions (emit(), on())

All 38 tests pass:

tox -e unit -- tests/infrastructure/test_event_bus.py
# 38 passed, 99.3% coverage

The issue appears to have been generated by a detection script that incorrectly reported "0 tests" for this file. The tests were likely added after the issue was created or the detection script had a false negative.

Recommendation: Close this issue as the tests are comprehensive and passing.

## Investigation Complete The unit tests for `src/infrastructure/events/bus.py` **already exist** at `tests/infrastructure/test_event_bus.py`. **Test Coverage:** 99.3% (153/154 lines covered) **Tests Include:** - ✅ Event dataclass (`TestEvent`) - ✅ Subscribe/publish/unsubscribe (`TestEventBus`) - ✅ Wildcard pattern matching (`agent.*`, `*`) - ✅ Error handling (handler exceptions don't break other handlers) - ✅ In-memory history with filtering by type/source/limit - ✅ SQLite persistence with WAL mode (`TestEventBusPersistence`) - ✅ Replay functionality with filters (type, source, task_id) - ✅ Singleton helpers (`get_event_bus()`, `init_event_bus_persistence()`) - ✅ Convenience functions (`emit()`, `on()`) **All 38 tests pass:** ``` tox -e unit -- tests/infrastructure/test_event_bus.py # 38 passed, 99.3% coverage ``` The issue appears to have been generated by a detection script that incorrectly reported "0 tests" for this file. The tests were likely added after the issue was created or the detection script had a false negative. **Recommendation:** Close this issue as the tests are comprehensive and passing.
kimi closed this issue 2026-03-23 22:47:29 +00:00
Sign in to join this conversation.
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Rockachopa/Timmy-time-dashboard#1212