49 lines
1.3 KiB
Python
49 lines
1.3 KiB
Python
"""Severity breakdown helper for console output."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from applepy.findings import Finding, Severity, severity_breakdown_line
|
|
|
|
|
|
def test_severity_breakdown_line_all_levels() -> None:
|
|
findings = [
|
|
Finding(
|
|
id="1",
|
|
title="a",
|
|
category="c",
|
|
severity=Severity.CRITICAL,
|
|
description="d",
|
|
evidence="e",
|
|
worksheet="W",
|
|
),
|
|
Finding(
|
|
id="2",
|
|
title="b",
|
|
category="c",
|
|
severity=Severity.HIGH,
|
|
description="d",
|
|
evidence="e",
|
|
worksheet="W",
|
|
),
|
|
Finding(
|
|
id="3",
|
|
title="c",
|
|
category="c",
|
|
severity=Severity.INFORMATIONAL,
|
|
description="d",
|
|
evidence="e",
|
|
worksheet="W",
|
|
),
|
|
]
|
|
line = severity_breakdown_line(findings)
|
|
assert "critical: 1" in line
|
|
assert "high: 1" in line
|
|
assert "medium: 0" in line
|
|
assert "low: 0" in line
|
|
assert "informational: 1" in line
|
|
|
|
|
|
def test_severity_breakdown_line_empty() -> None:
|
|
line = severity_breakdown_line([])
|
|
assert line == "critical: 0 · high: 0 · medium: 0 · low: 0 · informational: 0"
|