refactor(fam-core): 移除 SS Webhook 可选路径与 NAS 静态前端托管,兜底 Oracle 地址更新为 129.146.26.249
This commit is contained in:
@@ -11,7 +11,6 @@ def _cfg(**overrides):
|
||||
"dsm_port": 5000,
|
||||
"dsm_account": "ericwyuan",
|
||||
"dsm_password": "secret",
|
||||
"camera_name_to_id": {"Generic_ONVIF-001": 2},
|
||||
"oracle_base_url": "http://oracle.example:5000",
|
||||
"oracle_token": "tok123",
|
||||
"heartbeat_interval_sec": 300,
|
||||
@@ -38,70 +37,6 @@ class _FakeResp:
|
||||
return self._payload
|
||||
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# build_event_from_webhook / 时间解析 / 摄像头映射
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
def test_build_event_from_webhook_maps_known_camera(monkeypatch):
|
||||
n = _make_notifier(monkeypatch)
|
||||
ev = n.build_event_from_webhook({
|
||||
"device_name": "Generic_ONVIF-001",
|
||||
"event_time": "2026-08-22T10:35:00",
|
||||
"thumbnail_url": "abc,123",
|
||||
})
|
||||
assert ev is not None
|
||||
assert ev["camera_id"] == 2
|
||||
assert ev["event_type"] == 10
|
||||
assert ev["duration"] == 0
|
||||
assert isinstance(ev["start_time"], int)
|
||||
|
||||
|
||||
def test_build_event_from_webhook_missing_fields_returns_none(monkeypatch):
|
||||
n = _make_notifier(monkeypatch)
|
||||
assert n.build_event_from_webhook({"device_name": "Generic_ONVIF-001"}) is None
|
||||
assert n.build_event_from_webhook({"event_time": "2026-08-22T10:35:00"}) is None
|
||||
|
||||
|
||||
def test_build_event_from_webhook_unmapped_camera_gives_none_id(monkeypatch):
|
||||
n = _make_notifier(monkeypatch)
|
||||
ev = n.build_event_from_webhook({
|
||||
"device_name": "某个从没见过的摄像头",
|
||||
"event_time": "2026-08-22T10:35:00",
|
||||
})
|
||||
assert ev is not None
|
||||
assert ev["camera_id"] is None
|
||||
|
||||
|
||||
def test_synth_event_id_stable_for_same_input(monkeypatch):
|
||||
n = _make_notifier(monkeypatch)
|
||||
a = n._synth_event_id("cam1", "2026-08-22T10:00:00", "thumb1")
|
||||
b = n._synth_event_id("cam1", "2026-08-22T10:00:00", "thumb1")
|
||||
assert a == b
|
||||
|
||||
|
||||
def test_synth_event_id_differs_for_different_thumbnail(monkeypatch):
|
||||
"""核心诉求: 同一分钟内的多次真实事件要能区分开,不能因为哈希碰撞被去重掉。"""
|
||||
n = _make_notifier(monkeypatch)
|
||||
a = n._synth_event_id("cam1", "2026-08-22T10:00:00", "thumb1")
|
||||
b = n._synth_event_id("cam1", "2026-08-22T10:00:00", "thumb2")
|
||||
assert a != b
|
||||
|
||||
|
||||
def test_parse_ss_time_to_epoch_iso_format(monkeypatch):
|
||||
n = _make_notifier(monkeypatch)
|
||||
assert n.parse_ss_time_to_epoch("2026-08-22T10:35:00") is not None
|
||||
|
||||
|
||||
def test_parse_ss_time_to_epoch_invalid_returns_none(monkeypatch):
|
||||
n = _make_notifier(monkeypatch)
|
||||
assert n.parse_ss_time_to_epoch("not a time") is None
|
||||
|
||||
|
||||
def test_parse_ss_time_to_epoch_empty_returns_none(monkeypatch):
|
||||
n = _make_notifier(monkeypatch)
|
||||
assert n.parse_ss_time_to_epoch("") is None
|
||||
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# 心跳(跟轮询无关,enabled=true 就该跑)
|
||||
# ----------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user