"""
T-NEU: Neutralization config verification.

Verifies that neutralization is configured and enabled
for both demo mandates.
"""

import pytest
from tests.demo.conftest import _getFeatureInstances


class TestNeutralizationConfig:

    @pytest.mark.parametrize("mandateFixture", ["mandateHappylife", "mandateAlpina"])
    def test_neutralizationEnabled(self, db, mandateFixture, request):
        """Neutralization must be enabled for both mandates."""
        mandate = request.getfixturevalue(mandateFixture)
        mid = mandate.get("id")
        instances = _getFeatureInstances(db, mid, "neutralization")
        assert instances, f"No neutralization instance in {mandate.get('label')}"

        from modules.features.neutralization.datamodelFeatureNeutralizer import DataNeutraliserConfig
        iid = instances[0].get("id")
        configs = db.getRecordset(DataNeutraliserConfig, recordFilter={"featureInstanceId": iid})
        assert configs, f"No neutralization config in {mandate.get('label')}"
        assert configs[0].get("enabled") is True, f"Neutralization not enabled in {mandate.get('label')}"


class TestNeutralizationTestData:

    def test_tenantDossierExists(self):
        """The tenant-dossier.pdf must exist in demoData."""
        from pathlib import Path
        dossier = Path(__file__).resolve().parent.parent.parent / "demoData" / "neutralizer" / "tenant-dossier.pdf"
        assert dossier.exists(), f"tenant-dossier.pdf not found at {dossier}"
        assert dossier.stat().st_size > 500, "tenant-dossier.pdf seems too small"
