• v0.1.0 44941b04e3

    feat: golden corpus — DadosEmissao JSON -> canonical pre-signature XML

    jonatan released this 2026-07-22 18:10:06 +00:00 | 1 commits to main since this release

    Adds golden_helpers (dados_from_json/serialize_infnfe, package modules so
    the auto's parity test and the future service can import them directly) and
    6 golden cases under src/sowai_fiscal/goldens/ as package data:

    • caso_padrao_intra: preset Padrao, PR->PR, CSOSN 102/CFOP 5102, 2 itens
    • caso_padrao_inter: PR->SP, CFOP 6102, idDest=2
    • caso_st_intra: Oleos, CSOSN 500/CFOP 5405, grupo ICMSSN500 (vBCSTRet/pST/vICMSSTRet)
    • caso_devolucao_intra: tipo_operacao devolucao, CFOP 1202
    • caso_com_ub: FiscalResult com linhas ibs/cbs (grupo UB presente -- builder
      suporta estruturalmente mesmo com o guard de emissao do auto bloqueando hoje)
    • caso_fracao_centavo: qty 1.5 x 0.01, 2 linhas -- prova o arredondamento
      por-item (soma_itens_quantizados) contra a soma bruta

    Every input pins dh_emi/cnf/chave_acesso for determinism. serialize_infnfe
    replicates the exact SerializerConfig(xml_declaration=False, indent=None) +
    ns_map used by the auto's emissao.py::_serialize_nfe before signing.

    scripts/gen_goldens.py regenerates the .expected.xml files; test_goldens.py
    compares byte-for-byte (parametrized per case, readable first-divergent-byte
    diff on failure). Verified the comparison has real detection power by
    corrupting one expected file and confirming the test fails, then restored.

    62 tests pass locally via uv run pytest.

    Downloads