def test_api_build_invoice(invoice_dict, monkeypatch): with monkeypatch.context() as m: def mock_resolve_validator(): class MockValidator: def validate(self, invoice): return invoice return MockValidator() m.setattr(facturark.api, "resolve_validator", mock_resolve_validator) def mock_resolve_identifier(kind, technical_key=None): class MockInvoiceIdentifier: def __init__(self, technical_key): self.technical_key = technical_key def identify(self, invoice): return "" return MockInvoiceIdentifier("ABC123") m.setattr(facturark.api, "resolve_identifier", mock_resolve_identifier) result = facturark.build_document(invoice_dict) assert result is not None
def test_api_build_debit_note(debit_note_dict, monkeypatch): with monkeypatch.context() as m: def mock_resolve_validator(): class MockValidator: def validate(self, invoice): return invoice return MockValidator() m.setattr(facturark.api, "resolve_validator", mock_resolve_validator) result = facturark.build_document(debit_note_dict, kind='debit_note') assert result is not None
def cli_build_document(options_dict): invoice_bytes = read_file(options_dict.get('input_file')) invoice_dict = json.loads(invoice_bytes.decode('utf-8')) certificate = (read_file(options_dict.get('certificate')) if options_dict.get('certificate') else None) password = options_dict.get('password') technical_key = options_dict.get('technical_key') kind = options_dict.get('kind') invoice_xml, _ = build_document(invoice_dict, certificate, password, technical_key, kind) output_file = options_dict.get('output_file') write_file(output_file, invoice_xml)
def cli_build_document(options_dict): invoice_bytes = read_file(options_dict.get("input_file")) invoice_dict = json.loads(invoice_bytes.decode("utf-8")) certificate = (read_file(options_dict.get("certificate")) if options_dict.get("certificate") else None) private_key = options_dict.get("private_key") technical_key = options_dict.get("technical_key") kind = options_dict.get("kind") invoice_xml, _ = build_document(invoice_dict, certificate, private_key, technical_key, kind) output_file = options_dict.get("output_file") write_file(output_file, invoice_xml)