Add event-taxonomy package with canonical schema, adapters, and CLI
Canonical NormalizedFinding schema with Severity enum (CRITICAL/HIGH/MEDIUM/LOW/INFO). Per-project adapters for 9 tools with severity mapping for string labels, int 1-10, float 0-1, Python Enum, and computed properties. CLI pipe interface and registry. Nightshift-Task: event-taxonomy Nightshift-Ref: https://github.com/marcus/nightshift
This commit is contained in:
60
tests/test_severity.py
Normal file
60
tests/test_severity.py
Normal file
@@ -0,0 +1,60 @@
|
||||
from event_taxonomy.adapters._severity import (
|
||||
map_doc_severity,
|
||||
map_entropy_risk,
|
||||
map_flakiness_rate,
|
||||
map_int_severity,
|
||||
map_risk_label,
|
||||
map_schema_risk,
|
||||
)
|
||||
from event_taxonomy.schema import Severity
|
||||
|
||||
|
||||
def test_risk_label_mapping():
|
||||
assert map_risk_label("CRITICAL") == Severity.CRITICAL
|
||||
assert map_risk_label("high") == Severity.HIGH
|
||||
assert map_risk_label("Medium") == Severity.MEDIUM
|
||||
assert map_risk_label("LOW") == Severity.LOW
|
||||
assert map_risk_label("OK") == Severity.INFO
|
||||
assert map_risk_label("unknown") == Severity.INFO
|
||||
|
||||
|
||||
def test_doc_severity_mapping():
|
||||
assert map_doc_severity("error") == Severity.HIGH
|
||||
assert map_doc_severity("warning") == Severity.MEDIUM
|
||||
assert map_doc_severity("info") == Severity.INFO
|
||||
assert map_doc_severity("ERROR") == Severity.HIGH
|
||||
|
||||
|
||||
def test_int_severity_boundaries():
|
||||
assert map_int_severity(10) == Severity.CRITICAL
|
||||
assert map_int_severity(8) == Severity.CRITICAL
|
||||
assert map_int_severity(7) == Severity.HIGH
|
||||
assert map_int_severity(6) == Severity.HIGH
|
||||
assert map_int_severity(5) == Severity.MEDIUM
|
||||
assert map_int_severity(4) == Severity.MEDIUM
|
||||
assert map_int_severity(3) == Severity.LOW
|
||||
assert map_int_severity(2) == Severity.LOW
|
||||
assert map_int_severity(1) == Severity.INFO
|
||||
|
||||
|
||||
def test_schema_risk_mapping():
|
||||
assert map_schema_risk("dangerous") == Severity.CRITICAL
|
||||
assert map_schema_risk("cautious") == Severity.MEDIUM
|
||||
assert map_schema_risk("safe") == Severity.LOW
|
||||
assert map_schema_risk("Dangerous") == Severity.CRITICAL
|
||||
|
||||
|
||||
def test_entropy_risk_mapping():
|
||||
assert map_entropy_risk("critical") == Severity.CRITICAL
|
||||
assert map_entropy_risk("high") == Severity.HIGH
|
||||
assert map_entropy_risk("moderate") == Severity.MEDIUM
|
||||
assert map_entropy_risk("low") == Severity.LOW
|
||||
|
||||
|
||||
def test_flakiness_rate_boundaries():
|
||||
assert map_flakiness_rate(0.0) == Severity.INFO
|
||||
assert map_flakiness_rate(0.05) == Severity.LOW
|
||||
assert map_flakiness_rate(0.15) == Severity.MEDIUM
|
||||
assert map_flakiness_rate(0.3) == Severity.HIGH
|
||||
assert map_flakiness_rate(0.5) == Severity.CRITICAL
|
||||
assert map_flakiness_rate(1.0) == Severity.CRITICAL
|
||||
Reference in New Issue
Block a user