mirror of
https://github.com/msoedov/agentic_security.git
synced 2026-06-23 21:59:57 +02:00
fix(use_agg_backend):
This commit is contained in:
@@ -59,7 +59,6 @@ def _plot_security_report(table: Table) -> io.BytesIO:
|
||||
Returns:
|
||||
io.BytesIO: A buffer containing the generated plot image in PNG format.
|
||||
"""
|
||||
return io.BytesIO()
|
||||
# Data preprocessing
|
||||
logger.info("Data preprocessing started.")
|
||||
|
||||
|
||||
@@ -2,8 +2,7 @@ import io
|
||||
|
||||
import matplotlib
|
||||
import pytest
|
||||
|
||||
matplotlib.use("Agg")
|
||||
from inline_snapshot import snapshot
|
||||
|
||||
from agentic_security.report_chart import (
|
||||
_generate_identifiers,
|
||||
@@ -12,6 +11,11 @@ from agentic_security.report_chart import (
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def use_agg_backend():
|
||||
matplotlib.use("Agg")
|
||||
|
||||
|
||||
class TestGenerateIdentifiers:
|
||||
def test_single_row(self):
|
||||
data = type("DF", (), {"__len__": lambda s: 1})()
|
||||
@@ -58,7 +62,10 @@ class TestPlotSecurityReport:
|
||||
{"module": "mod_c", "failureRate": 25.0, "tokens": 500},
|
||||
]
|
||||
result = plot_security_report(table_data)
|
||||
assert result.getvalue() != b""
|
||||
# A real plot was rendered: non-empty buffer carrying the PNG signature.
|
||||
png = result.getvalue()
|
||||
assert len(png) > 0
|
||||
assert png[:8] == snapshot(b"\x89PNG\r\n\x1a\n")
|
||||
|
||||
def test_handles_empty_data(self):
|
||||
result = plot_security_report([])
|
||||
|
||||
Reference in New Issue
Block a user