New standalone Python/FastAPI service for automatic compliance document scanning, LLM-based classification, IPFS archival, and gap analysis. Includes extractors (PDF, DOCX, XLSX, PPTX), keyword fallback classifier, compliance matrix, and full REST API on port 8098. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
47 lines
1.5 KiB
Python
47 lines
1.5 KiB
Python
"""Tests for gap analysis."""
|
|
|
|
import pytest
|
|
from gap_analysis.analyzer import generate_gap_analysis
|
|
|
|
|
|
def test_full_compliance():
|
|
counts = {
|
|
"VVT": 1, "TOM": 1, "DSE": 1, "Loeschkonzept": 1,
|
|
"Richtlinie": 1, "Schulungsnachweis": 1, "AVV": 1, "DSFA": 1,
|
|
}
|
|
result = generate_gap_analysis(counts)
|
|
assert result["compliance_score"] == 100.0
|
|
assert len(result["gaps"]) == 0
|
|
|
|
|
|
def test_no_documents():
|
|
result = generate_gap_analysis({})
|
|
assert result["compliance_score"] == 0.0
|
|
assert len(result["gaps"]) > 0
|
|
assert result["gap_summary"]["critical"] > 0
|
|
|
|
|
|
def test_partial_compliance():
|
|
counts = {"VVT": 1, "TOM": 1}
|
|
result = generate_gap_analysis(counts)
|
|
assert 0 < result["compliance_score"] < 100
|
|
# DSE, Loeschkonzept, Richtlinie, Schulungsnachweis, AVV, DSFA should be gaps
|
|
gap_categories = [g["category"] for g in result["gaps"]]
|
|
assert "DSE" in gap_categories
|
|
assert "Loeschkonzept" in gap_categories
|
|
|
|
|
|
def test_universal_only():
|
|
counts = {"VVT": 1, "TOM": 1, "DSE": 1, "Loeschkonzept": 1}
|
|
result = generate_gap_analysis(counts, company_profiles=["universal"])
|
|
# Universal requires VVT, TOM, DSE, Loeschkonzept, Richtlinie, Schulungsnachweis
|
|
# 4 out of 6 covered
|
|
assert result["covered"] == 4
|
|
assert result["total_required"] == 6
|
|
|
|
|
|
def test_gap_severity():
|
|
result = generate_gap_analysis({}, company_profiles=["universal"])
|
|
severities = {g["severity"] for g in result["gaps"]}
|
|
assert "CRITICAL" in severities
|