36 lines
1.2 KiB
Python
36 lines
1.2 KiB
Python
import sys
|
|
import os
|
|
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'app')))
|
|
|
|
from core.diagnostics import analyze_frames
|
|
|
|
def test_missing_status_after_boot():
|
|
frames = [
|
|
{"action": "BootNotification", "uniqueId": "1", "payload": {}},
|
|
{"action": "Heartbeat", "uniqueId": "2", "payload": {}}
|
|
]
|
|
findings = analyze_frames(frames, {})
|
|
assert len(findings) == 1
|
|
assert findings[0]["id"] == "NO_STATUS_AFTER_BOOT"
|
|
|
|
def test_no_finding_when_status_present():
|
|
frames = [
|
|
{"action": "BootNotification", "uniqueId": "1", "payload": {}},
|
|
{"action": "StatusNotification", "uniqueId": "2", "payload": {"status": "Available"}}
|
|
]
|
|
findings = analyze_frames(frames, {})
|
|
assert len(findings) == 0
|
|
|
|
def test_clock_drift_none():
|
|
findings = analyze_frames([], {"clock_drift": None})
|
|
assert len(findings) == 0
|
|
|
|
def test_clock_drift_critical():
|
|
findings = analyze_frames([], {"clock_drift": 120})
|
|
assert len(findings) == 1
|
|
assert findings[0]["id"] == "CLOCK_DRIFT"
|
|
|
|
def test_abnormal_disconnect():
|
|
findings = analyze_frames([], {"last_disconnect_code": 1006})
|
|
assert len(findings) == 1
|
|
assert findings[0]["id"] == "ABNORMAL_DISCONNECT"
|