[loop-generated] [test] Add unit tests for event bus (bus.py) — 356 lines, 0 tests #1191

Closed
opened 2026-03-23 21:53:15 +00:00 by Timmy · 2 comments
Owner

Problem

src/infrastructure/events/bus.py is 356 lines with zero test coverage. The event bus is core infrastructure — it routes events between components.

Acceptance Criteria

  • Create tests/infrastructure/test_event_bus.py
  • Test event registration, publishing, and subscriber notification
  • Test error handling in subscribers
  • Test async event handling if applicable
  • All new tests pass via tox -e unit
  • No changes to production code unless fixing discovered bugs
## Problem `src/infrastructure/events/bus.py` is 356 lines with zero test coverage. The event bus is core infrastructure — it routes events between components. ## Acceptance Criteria - [ ] Create `tests/infrastructure/test_event_bus.py` - [ ] Test event registration, publishing, and subscriber notification - [ ] Test error handling in subscribers - [ ] Test async event handling if applicable - [ ] All new tests pass via `tox -e unit` - [ ] No changes to production code unless fixing discovered bugs
claude self-assigned this 2026-03-23 21:53:29 +00:00
Author
Owner

Kimi instructions:

  • File: src/infrastructure/events/bus.py
  • Create: tests/infrastructure/test_event_bus.py
  • Read the bus.py source, identify all public methods
  • Write tests for each: subscribe, publish, unsubscribe
  • Mock external dependencies
  • Run tox -e unit to verify
  • Target: 10+ test cases
Kimi instructions: - File: `src/infrastructure/events/bus.py` - Create: `tests/infrastructure/test_event_bus.py` - Read the bus.py source, identify all public methods - Write tests for each: subscribe, publish, unsubscribe - Mock external dependencies - Run `tox -e unit` to verify - Target: 10+ test cases
Collaborator

PR created: #1201

The base test suite (30 tests) already existed from a prior commit. This PR adds 8 more tests covering the previously uncovered paths:

  • get_event_bus() singleton, init_event_bus_persistence() (idempotency + default path), module __getattr__ error path
  • Exception-swallowing in _persist_event() and replay()

Coverage: 92.7% → 99.3% (38 tests passing).

PR created: #1201 The base test suite (30 tests) already existed from a prior commit. This PR adds 8 more tests covering the previously uncovered paths: - `get_event_bus()` singleton, `init_event_bus_persistence()` (idempotency + default path), module `__getattr__` error path - Exception-swallowing in `_persist_event()` and `replay()` Coverage: **92.7% → 99.3%** (38 tests passing).
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#1191