feature/correcion-hash
This commit is contained in:
@@ -5,7 +5,7 @@ from core.exceptions import ErrorCollector
|
||||
|
||||
|
||||
def test_build_configuracion_vu_returns_validation_error_when_vu_is_missing() -> None:
|
||||
service = FacturaCoveDomainService(db=SimpleNamespace())
|
||||
service = FacturaCoveDomainService(db=SimpleNamespace(get=lambda *args, **kwargs: None))
|
||||
ctx = InvoiceContext(
|
||||
invoice=SimpleNamespace(),
|
||||
broker=None,
|
||||
@@ -20,10 +20,82 @@ def test_build_configuracion_vu_returns_validation_error_when_vu_is_missing() ->
|
||||
assert errors.get_errors() == [
|
||||
{
|
||||
"field": "vu",
|
||||
"message": "La factura no tiene configuración VU asociada en el agente aduanal",
|
||||
"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 y sube certificado (.cer) y llave (.key) antes de generar COVE."
|
||||
"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",
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user