mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-31 19:45:15 +02:00
feat(event_bus): add EventCatalog class with register/get/all methods
This commit is contained in:
parent
30fff9e52f
commit
2a511b8559
3 changed files with 146 additions and 0 deletions
25
surfsense_backend/tests/unit/event_bus/conftest.py
Normal file
25
surfsense_backend/tests/unit/event_bus/conftest.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
"""Shared fixtures for the ``app.event_bus`` unit-test tree.
|
||||
|
||||
The event-type catalog is a module-level registry populated at import. Tests
|
||||
that register their own event types (or assert on registry contents) snapshot
|
||||
and restore it so state never leaks between tests.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Iterator
|
||||
|
||||
import pytest
|
||||
|
||||
from app.event_bus.catalog import catalog
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def isolated_event_catalog() -> Iterator[None]:
|
||||
"""Snapshot and restore the event-type catalog around a test."""
|
||||
snapshot = dict(catalog._registry)
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
catalog._registry.clear()
|
||||
catalog._registry.update(snapshot)
|
||||
Loading…
Add table
Add a link
Reference in a new issue