remove infra.md.example, infra.md is the source of truth
This commit is contained in:
54
ayn-antivirus/tests/test_reports.py
Normal file
54
ayn-antivirus/tests/test_reports.py
Normal file
@@ -0,0 +1,54 @@
|
||||
import json
|
||||
import pytest
|
||||
from datetime import datetime
|
||||
from ayn_antivirus.core.engine import ScanResult, ScanType, ThreatInfo, ThreatType, Severity
|
||||
from ayn_antivirus.reports.generator import ReportGenerator
|
||||
|
||||
def _make_scan_result():
|
||||
return ScanResult(
|
||||
scan_id="test-001",
|
||||
start_time=datetime.now(),
|
||||
end_time=datetime.now(),
|
||||
files_scanned=500,
|
||||
files_skipped=10,
|
||||
threats=[
|
||||
ThreatInfo(
|
||||
path="/tmp/evil.sh",
|
||||
threat_name="ReverseShell",
|
||||
threat_type=ThreatType.MALWARE,
|
||||
severity=Severity.CRITICAL,
|
||||
detector_name="heuristic",
|
||||
details="Reverse shell detected",
|
||||
file_hash="abc123"
|
||||
)
|
||||
],
|
||||
scan_path="/tmp",
|
||||
scan_type=ScanType.FULL
|
||||
)
|
||||
|
||||
def test_text_report():
|
||||
gen = ReportGenerator()
|
||||
result = _make_scan_result()
|
||||
text = gen.generate_text(result)
|
||||
assert "AYN ANTIVIRUS" in text
|
||||
assert "ReverseShell" in text
|
||||
|
||||
def test_json_report():
|
||||
gen = ReportGenerator()
|
||||
result = _make_scan_result()
|
||||
j = gen.generate_json(result)
|
||||
data = json.loads(j)
|
||||
assert data["summary"]["total_threats"] == 1
|
||||
|
||||
def test_html_report():
|
||||
gen = ReportGenerator()
|
||||
result = _make_scan_result()
|
||||
html = gen.generate_html(result)
|
||||
assert "<html" in html
|
||||
assert "ReverseShell" in html
|
||||
assert "CRITICAL" in html
|
||||
|
||||
def test_save_report(tmp_path):
|
||||
gen = ReportGenerator()
|
||||
gen.save_report("test content", str(tmp_path / "report.txt"))
|
||||
assert (tmp_path / "report.txt").read_text() == "test content"
|
||||
Reference in New Issue
Block a user