From 71e9a6e9167268c2d5746418b3db80722fb6ec9e Mon Sep 17 00:00:00 2001 From: AlexeerCT Date: Mon, 13 Apr 2026 18:35:58 -0500 Subject: [PATCH] Remove unit tests for FacturaCoveDomainService related to VU configuration validation --- .../tests/unit/factura_cove/test_service.py | 101 ------------------ 1 file changed, 101 deletions(-) delete mode 100644 backend/tests/unit/factura_cove/test_service.py diff --git a/backend/tests/unit/factura_cove/test_service.py b/backend/tests/unit/factura_cove/test_service.py deleted file mode 100644 index 71ca8466..00000000 --- a/backend/tests/unit/factura_cove/test_service.py +++ /dev/null @@ -1,101 +0,0 @@ -from types import SimpleNamespace - -from api.v1.modules.a76.factura_cove.service import FacturaCoveDomainService, InvoiceContext -from core.exceptions import ErrorCollector - - -def test_build_configuracion_vu_returns_validation_error_when_vu_is_missing() -> None: - service = FacturaCoveDomainService(db=SimpleNamespace(get=lambda *args, **kwargs: None)) - ctx = InvoiceContext( - invoice=SimpleNamespace(), - broker=None, - vu=None, - ) - errors = ErrorCollector() - - configuracion = service._build_configuracion_vu(ctx, errors) - - assert configuracion is None - assert errors.has_errors() - assert errors.get_errors() == [ - { - "field": "vu", - "message": "La factura no tiene configuración VU asociada ni configuración VU/certificado FIEL en la empresa", - "solution": [ - "Configura los datos VU del agente aduanal o de la empresa y sube certificado (.cer) y llave (.key) antes de generar COVE." - ], - "code": "MISSING_VU_CONFIGURATION", - } - ] - - -def test_build_configuracion_vu_uses_company_fiel_when_vu_has_no_fiel(monkeypatch) -> None: - company = SimpleNamespace( - ventanilla_unica=SimpleNamespace( - webservice_user="company-ws-user", - webservice_password="company-ws-pass", - query_rfc="RFCEMPRESA123", - ), - digital_certificates=[ - SimpleNamespace( - certificate_type="fiel", - access_key="company-fiel-access", - cer_file_path="company/fiel.cer", - key_file_path="company/fiel.key", - ) - ], - ) - service = FacturaCoveDomainService(db=SimpleNamespace(get=lambda *args, **kwargs: company)) - monkeypatch.setattr("api.v1.modules.a76.factura_cove.service.object_exists", lambda path: True) - monkeypatch.setattr( - "api.v1.modules.a76.factura_cove.service.get_object_bytes", - lambda path: f"content:{path}".encode("utf-8"), - ) - ctx = InvoiceContext(invoice=SimpleNamespace(company_id=10), broker=None, vu=None) - errors = ErrorCollector() - - configuracion = service._build_configuracion_vu(ctx, errors) - - assert configuracion is not None - assert not errors.has_errors() - assert configuracion.rfc_usuario_vu == "RFCEMPRESA123" - assert configuracion.clave_webservice == "company-ws-pass" - assert configuracion.clave_fiel == "company-fiel-access" - - -def test_build_configuracion_vu_reports_missing_fiel_when_absent_in_vu_and_company(monkeypatch) -> None: - company = SimpleNamespace( - ventanilla_unica=SimpleNamespace( - webservice_user="company-ws-user", - webservice_password="company-ws-pass", - query_rfc="RFCEMPRESA123", - ), - digital_certificates=[], - ) - service = FacturaCoveDomainService(db=SimpleNamespace(get=lambda *args, **kwargs: company)) - vu = SimpleNamespace( - web_service_user="", - doda_web_service_user=None, - fiel_access_key=None, - certificate_path="cert.cer", - key_path="key.key", - query_tax_id="", - web_service_access_key="", - ) - ctx = InvoiceContext(invoice=SimpleNamespace(company_id=10), broker=None, vu=vu) - errors = ErrorCollector() - - configuracion = service._build_configuracion_vu(ctx, errors) - - assert configuracion is None - assert errors.has_errors() - assert errors.get_errors() == [ - { - "field": "vu.clave_fiel", - "message": "La clave FIEL para COVE no está configurada ni en VU ni en la empresa.", - "solution": [ - "Captura la clave FIEL en la configuración VU del agente aduanal o en el certificado FIEL de la empresa." - ], - "code": "MISSING_FIEL_PASSWORD", - } - ] \ No newline at end of file