From d861c9a6ff23c4f084ffd5645ac84c4d1de2ba0e Mon Sep 17 00:00:00 2001 From: Frederik Jaeckel Date: Wed, 18 Dec 2024 17:23:01 +0100 Subject: [PATCH] add test --- tests/facturx-extended.xml | 114 +++++++++++++++++++++++++++++++++++++ tests/test_invoice.py | 52 +++++++++++++++++ 2 files changed, 166 insertions(+) create mode 100644 tests/facturx-extended.xml diff --git a/tests/facturx-extended.xml b/tests/facturx-extended.xml new file mode 100644 index 0000000..ce384cb --- /dev/null +++ b/tests/facturx-extended.xml @@ -0,0 +1,114 @@ + + + + + urn:cen.eu:en16931:2017#conformant#urn:factur-x.eu:1p0:extended + + + + RE2024.01234 + 380 + + 20240617 + + + Some notes to the customer. + + + + + + 1 + + + Name of Product 1 + Description of Product 1 + + + + 1350.00 + + + + 1.0 + + + + VAT + S + 19.00 + + + 1350.00 + + + + + + Name of the Comany + + + + 12345 + Street of Company No 1 + Berlin + DE + Berlin + + + + Customer Company + + + + 23456 + Address Line 1 + Address Line 2 + Potsdam + DE + Brandenburg + + + + + + + + + + RE2024.01234 + EUR + + 30 + Wire transfer + + DE02300209000106531065 + mbs + + + WELADED1PMB + + + + 256.5 + VAT + 1350 + S + 19.00 + + + + 20240701 + + 1606.50 + + + 1350.00 + 1350.00 + 256.5 + 1606.50 + 1606.50 + + + + diff --git a/tests/test_invoice.py b/tests/test_invoice.py index d502547..f712a5c 100644 --- a/tests/test_invoice.py +++ b/tests/test_invoice.py @@ -3,6 +3,7 @@ # from m-ds for Tryton. The COPYRIGHT file at the top level of # this repository contains the full copyright notices and license terms. +import os.path from decimal import Decimal from datetime import date from facturx import get_facturx_xml_from_pdf @@ -109,6 +110,57 @@ class InvoiceTestCase(ModuleTestCase): self.assertEqual(len(inv_lst.move.lines), 3) return inv_lst + @with_transaction() + def test_wiz_import_single_xml(self): + """ run import wizard, upload a single file + """ + pool = Pool() + ImportWiz = pool.get( + 'account_invoice_xrechnung.import', type='wizard') + + company1 = create_company('m-ds') + with Transaction().set_context({ + 'company': company1.id, + 'active_model': 'party.party'}): + (sess_id, start_state, end_state) = ImportWiz.create() + w_obj = ImportWiz(sess_id) + self.assertEqual(start_state, 'start') + self.assertEqual(end_state, 'end') + + # run start + result = ImportWiz.execute(sess_id, {}, start_state) + self.assertEqual(list(result.keys()), ['view']) + + step_values = { + x: result['view']['defaults'][x] + for x in result['view']['defaults'].keys() + if '.' not in x} + + self.assertEqual(step_values, { + 'company': company1.id, + 'invoice_type': 'in', + 'file_': None}) + + # step 1: upload xml-file + with open(os.path.join( + os.path.split(__file__)[0], + 'facturx-extended.xml'), 'rb') as fhdl: + step_values['file_'] = fhdl.read() + for i in step_values.keys(): + setattr(w_obj.start, i, step_values[i]) + + result = ImportWiz.execute( + sess_id, {start_state: step_values}, 'doupload') + + step_values = { + x: result['view']['defaults'][x] + for x in result['view']['defaults'].keys() + if '.' not in x} + + self.assertEqual(step_values, { + 'company': company1.id, + 'invoice_type': 'in'}) + @with_transaction() def test_xrechnung_configuration(self): """ test configuration