mirror of
https://github.com/zvx-echo6/central.git
synced 2026-05-21 18:14:44 +02:00
fix(adapters): complete self-describing adapter attributes
- Replace settings_schema classmethod with Pydantic model class attribute - Add display_name, description, requires_api_key, wizard_order, default_cadence_s - Remove stream_name from adapters (JetStream routes by subject filter) - Define NWSSettings, FIRMSSettings, USGSQuakeSettings Pydantic models - Make discover_adapters() public with error handling - Move adapter registry to Supervisor instance (self._adapters) - Add subject_for tests for all 6 quake magnitude tiers - Fix test_supervisor_integration to use injected mock adapters Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
4573bf6ee2
commit
4ee3d8bd14
7 changed files with 418 additions and 315 deletions
|
|
@ -480,3 +480,122 @@ class TestApplyConfig:
|
|||
assert adapter._feed == "all_day"
|
||||
|
||||
await adapter.shutdown()
|
||||
|
||||
|
||||
|
||||
class TestSubjectFor:
|
||||
"""Test subject_for method for all magnitude tiers."""
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_subject_minor(self, temp_db_path, mock_config_store):
|
||||
config = make_adapter_config()
|
||||
adapter = USGSQuakeAdapter(
|
||||
config=config,
|
||||
config_store=mock_config_store,
|
||||
cursor_db_path=temp_db_path,
|
||||
)
|
||||
event = Event(
|
||||
id="test-minor",
|
||||
adapter="usgs_quake",
|
||||
category="quake.event.minor",
|
||||
time=datetime.now(timezone.utc),
|
||||
severity=0,
|
||||
geo=Geo(centroid=(-116.0, 45.0)),
|
||||
data={},
|
||||
)
|
||||
assert adapter.subject_for(event) == "central.quake.event.minor"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_subject_light(self, temp_db_path, mock_config_store):
|
||||
config = make_adapter_config()
|
||||
adapter = USGSQuakeAdapter(
|
||||
config=config,
|
||||
config_store=mock_config_store,
|
||||
cursor_db_path=temp_db_path,
|
||||
)
|
||||
event = Event(
|
||||
id="test-light",
|
||||
adapter="usgs_quake",
|
||||
category="quake.event.light",
|
||||
time=datetime.now(timezone.utc),
|
||||
severity=1,
|
||||
geo=Geo(centroid=(-116.0, 45.0)),
|
||||
data={},
|
||||
)
|
||||
assert adapter.subject_for(event) == "central.quake.event.light"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_subject_moderate(self, temp_db_path, mock_config_store):
|
||||
config = make_adapter_config()
|
||||
adapter = USGSQuakeAdapter(
|
||||
config=config,
|
||||
config_store=mock_config_store,
|
||||
cursor_db_path=temp_db_path,
|
||||
)
|
||||
event = Event(
|
||||
id="test-moderate",
|
||||
adapter="usgs_quake",
|
||||
category="quake.event.moderate",
|
||||
time=datetime.now(timezone.utc),
|
||||
severity=2,
|
||||
geo=Geo(centroid=(-116.0, 45.0)),
|
||||
data={},
|
||||
)
|
||||
assert adapter.subject_for(event) == "central.quake.event.moderate"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_subject_strong(self, temp_db_path, mock_config_store):
|
||||
config = make_adapter_config()
|
||||
adapter = USGSQuakeAdapter(
|
||||
config=config,
|
||||
config_store=mock_config_store,
|
||||
cursor_db_path=temp_db_path,
|
||||
)
|
||||
event = Event(
|
||||
id="test-strong",
|
||||
adapter="usgs_quake",
|
||||
category="quake.event.strong",
|
||||
time=datetime.now(timezone.utc),
|
||||
severity=3,
|
||||
geo=Geo(centroid=(-116.0, 45.0)),
|
||||
data={},
|
||||
)
|
||||
assert adapter.subject_for(event) == "central.quake.event.strong"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_subject_major(self, temp_db_path, mock_config_store):
|
||||
config = make_adapter_config()
|
||||
adapter = USGSQuakeAdapter(
|
||||
config=config,
|
||||
config_store=mock_config_store,
|
||||
cursor_db_path=temp_db_path,
|
||||
)
|
||||
event = Event(
|
||||
id="test-major",
|
||||
adapter="usgs_quake",
|
||||
category="quake.event.major",
|
||||
time=datetime.now(timezone.utc),
|
||||
severity=4,
|
||||
geo=Geo(centroid=(-116.0, 45.0)),
|
||||
data={},
|
||||
)
|
||||
assert adapter.subject_for(event) == "central.quake.event.major"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_subject_great(self, temp_db_path, mock_config_store):
|
||||
config = make_adapter_config()
|
||||
adapter = USGSQuakeAdapter(
|
||||
config=config,
|
||||
config_store=mock_config_store,
|
||||
cursor_db_path=temp_db_path,
|
||||
)
|
||||
event = Event(
|
||||
id="test-great",
|
||||
adapter="usgs_quake",
|
||||
category="quake.event.great",
|
||||
time=datetime.now(timezone.utc),
|
||||
severity=5,
|
||||
geo=Geo(centroid=(-116.0, 45.0)),
|
||||
data={},
|
||||
)
|
||||
assert adapter.subject_for(event) == "central.quake.event.great"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue