mirror of
https://github.com/bringout/oca-edi.git
synced 2026-04-23 08:32:00 +02:00
Initial commit: OCA Edi packages (42 packages)
This commit is contained in:
commit
df976c03db
2184 changed files with 571602 additions and 0 deletions
|
|
@ -0,0 +1,3 @@
|
|||
from . import test_base_wamas_ubl
|
||||
from . import test_wamas_lib
|
||||
from . import test_record_data_to_wamas
|
||||
|
|
@ -0,0 +1 @@
|
|||
ODOO WAMAS 00000120231221041251LST000051 Adam Smith adam@dayrep.com 79782 Sand Springs Texas US 432-393-1264 aaa Standard 0N JStandard N
|
||||
|
|
@ -0,0 +1 @@
|
|||
ODOO WAMAS 00000120231221041251XYZ0000510000001 Adam Smith adam@dayrep.com 79782 Sand Springs Texas US 432-393-1264 aaa Standard 0N JStandard N
|
||||
|
|
@ -0,0 +1 @@
|
|||
ODOO WAMAS 00000120231221041251LST0000510000001 Adam Smith adam@dayrep.com 79782 Sand Springs Texas US 432-393-1264 aaa Standard 0N JStandard N
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
- Error: Line of length 660 does not match expected length of 667:
|
||||
ODOO WAMAS 00000120231221041251LST000051 Adam Smith adam@dayrep.com 79782 Sand Springs Texas US 432-393-1264 aaa Standard 0N JStandard N
|
||||
|
|
@ -0,0 +1 @@
|
|||
- Error: Invalid telegram type: XYZ
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
{
|
||||
"wamas_type": "Supplier",
|
||||
"data": {
|
||||
"LST": [
|
||||
{
|
||||
"Lst_Adrs_Adr": "adam@dayrep.com",
|
||||
"Lst_Adrs_Adr2": "",
|
||||
"Lst_Adrs_Anrede": "",
|
||||
"Lst_Adrs_Email": "aaa",
|
||||
"Lst_Adrs_Fax": "",
|
||||
"Lst_Adrs_ILN": "",
|
||||
"Lst_Adrs_Land": "US",
|
||||
"Lst_Adrs_Name": "Adam Smith",
|
||||
"Lst_Adrs_Name2": "",
|
||||
"Lst_Adrs_Name3": "",
|
||||
"Lst_Adrs_Name4": "",
|
||||
"Lst_Adrs_Ort": "Sand Springs",
|
||||
"Lst_Adrs_OrtTeil": "Texas",
|
||||
"Lst_Adrs_PLZ": "79782",
|
||||
"Lst_Adrs_Tel": "432-393-1264",
|
||||
"Lst_Adrs_WWW": "",
|
||||
"Lst_DVRNr": "",
|
||||
"Lst_LSTTYP_LstTypId": "Standard",
|
||||
"Lst_LiefNr": "0001",
|
||||
"Lst_LokLstTyp_AnzWeBeleg": "0",
|
||||
"Lst_LokLstTyp_LiefBewKz": "N",
|
||||
"Lst_LokLstTyp_StdLgTor": "",
|
||||
"Lst_LokLstTyp_StdRetTor": "",
|
||||
"Lst_LokLstTyp_StdWeTor": "",
|
||||
"Lst_LokLstTyp_UebLiefErl": "J",
|
||||
"Lst_LokLstTyp_WeBelegLay": "Standard",
|
||||
"Lst_Mand": "000",
|
||||
"Lst_PrueflosWeKz": "N",
|
||||
"Lst_SatzKz": "",
|
||||
"Lst_UIDNr": "",
|
||||
}
|
||||
]
|
||||
},
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
- WAMAS Type: Supplier
|
||||
- Data: {
|
||||
"LST": [
|
||||
{
|
||||
"Telheader_Quelle": "ODOO",
|
||||
"Telheader_Ziel": "WAMAS",
|
||||
"Telheader_TelSeq": 1,
|
||||
"Telheader_AnlZeit": "20231221041251",
|
||||
"Satzart": "LST000051",
|
||||
"Lst_Mand": "000",
|
||||
"Lst_LiefNr": "0001",
|
||||
"Lst_Adrs_Name": "Adam Smith",
|
||||
"Lst_Adrs_Name2": "",
|
||||
"Lst_Adrs_Name3": "",
|
||||
"Lst_Adrs_Name4": "",
|
||||
"Lst_Adrs_Anrede": "",
|
||||
"Lst_Adrs_Adr": "adam@dayrep.com",
|
||||
"Lst_Adrs_Adr2": "",
|
||||
"Lst_Adrs_PLZ": "79782",
|
||||
"Lst_Adrs_Ort": "Sand Springs",
|
||||
"Lst_Adrs_OrtTeil": "Texas",
|
||||
"Lst_Adrs_Land": "US",
|
||||
"Lst_Adrs_Fax": "",
|
||||
"Lst_Adrs_Tel": "432-393-1264",
|
||||
"Lst_Adrs_Email": "aaa",
|
||||
"Lst_Adrs_WWW": "",
|
||||
"Lst_Adrs_ILN": "",
|
||||
"Lst_UIDNr": "",
|
||||
"Lst_DVRNr": "",
|
||||
"Lst_LSTTYP_LstTypId": "Standard",
|
||||
"Lst_LokLstTyp_AnzWeBeleg": 0,
|
||||
"Lst_LokLstTyp_LiefBewKz": "N",
|
||||
"Lst_LokLstTyp_StdLgTor": "",
|
||||
"Lst_LokLstTyp_StdRetTor": "",
|
||||
"Lst_LokLstTyp_StdWeTor": "",
|
||||
"Lst_LokLstTyp_UebLiefErl": "J",
|
||||
"Lst_LokLstTyp_WeBelegLay": "Standard",
|
||||
"Lst_SatzKz": "",
|
||||
"Lst_PrueflosWeKz": "N"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"ref": "0001",
|
||||
"name": "Adam Smith",
|
||||
"street": "3273 Laurel Lane",
|
||||
"street2": "",
|
||||
"zip": "79782",
|
||||
"city": "Sand Springs",
|
||||
"state": "Texas",
|
||||
"country_code": "US",
|
||||
"phone": "432-393-1264",
|
||||
"email": "aaa",
|
||||
"street": "adam@dayrep.com",
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
ODOO WAMAS 00000120231221051251LST0000510000001 Adam Smith adam@dayrep.com 79782 Sand Springs Texas US 432-393-1264 aaa Standard 0N JStandard N
|
||||
|
|
@ -0,0 +1 @@
|
|||
ODOO WAMAS 00000120231221041251XYZ0000510000001 Adam Smith adam@dayrep.com 79782 Sand Springs Texas US 432-393-1264 aaa Standard 0N JStandard N
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
SYSLOG WAMAS 00000120231220091116WEAK00050000130377 HOST STDMAN0001040 SA Route de la Gare 1 Case postale 1525 Henniez +41 848 677 677 +41 26 668 68 68 customerservice.ch@waters.nestle.com 20230427000000
|
||||
SYSLOG WAMAS 00002020231220091116WEAP00045000130377 HOST 0000200001151 00000 NDISPONIBLE 000001536000BOUT NORMAL 20230501000000 202305010000007910063 NNLG
|
||||
SYSLOG WAMAS 00003020231220091116WEAP00045000130377 HOST 0000300001156 00000 NDISPONIBLE 000005184000PET NORMAL 20230501000000 202305010000007910105 NNLG
|
||||
SYSLOG WAMAS 00004020231220091116WEAP00045000130377 HOST 0000400001160 00000 NDISPONIBLE 000003840000BOUT NORMAL 20230501000000 202305010000007910004 NNLG
|
||||
SYSLOG WAMAS 00005020231220091116WEAP00045000130377 HOST 0000500001162 00000 NDISPONIBLE 000003072000PET NORMAL 20230501000000 2023050100000012156876 NNLG
|
||||
SYSLOG WAMAS 00006020231220091116WEAP00045000130377 HOST 0000600001176 00000 NDISPONIBLE 000003024000PET NORMAL 20230501000000 202305010000007910044 NNLG
|
||||
|
|
@ -0,0 +1 @@
|
|||
- Error: Invalid telegram type: XYZ
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
WAMAS ODOO 00000120230501000000WEAKQ0051000130377 HOST 19700101010000 19700101010000 20230501000000 0001040
|
||||
WAMAS ODOO 00000220230501000000WEAPQ0050000130377 000130377 HOST 000020 0001151 00000DISPONIBLE 000001536000000000000000 BOUT N
|
||||
WAMAS ODOO 00000320230501000000WEAPQ0050000130377 000130377 HOST 000030 0001156 00000DISPONIBLE 000005184000000000000000 PET N
|
||||
WAMAS ODOO 00000420230501000000WEAPQ0050000130377 000130377 HOST 000040 0001160 00000DISPONIBLE 000003840000000000000000 BOUT N
|
||||
WAMAS ODOO 00000520230501000000WEAPQ0050000130377 000130377 HOST 000050 0001162 00000DISPONIBLE 000003072000000000000000 PET N
|
||||
WAMAS ODOO 00000620230501000000WEAPQ0050000130377 000130377 HOST 000060 0001176 00000DISPONIBLE 000003024000000000000000 PET N
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"barcode": "256256256",
|
||||
"product": "113 113 113",
|
||||
"product_uom": "BOUT",
|
||||
"game_identifier": "N",
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
ODOO WAMAS 00000120231221051251ARTEAN001000113 113 113 00000256256256 BOUT N
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"product": "223 224 225",
|
||||
"width": 55,
|
||||
"height": 50,
|
||||
"weight": 1,
|
||||
"length": 10,
|
||||
"code": "CART",
|
||||
"game_identifier": "N",
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
ODOO WAMAS 00000120231221051251ARTE00051000223 224 225 00000000010000055000050CART 000000000001000000 CART 000000000000000000000000 000000000000000000000000N1000000000001000NNN
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"default_code": "113",
|
||||
"name": "The Yellow Chair",
|
||||
"uom": "Units",
|
||||
"weight": 2,
|
||||
"sell_only_by_packaging": False,
|
||||
"fifo_window": 999,
|
||||
"wamas_expiration_date": False,
|
||||
"wamas_assortment": "AA",
|
||||
"wamas_class": "BB",
|
||||
"product_uom_wamas_code": "HAR",
|
||||
"packaging_code": "Box",
|
||||
"packaging_level_palette_wamas_code": "CC",
|
||||
"standard_price": 0,
|
||||
"game_identifier": "N",
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
ODOO WAMAS 00000120231221051251ART000061000113 00000The Yellow Chair HAR Box N000000002000 AA STK STK N999BB GSMST - NJNJANALL_WA sdDEF sdDEF NNNN 999000000000000KANN ORIG99999999900099999999900005000500999999999000999999999999900099999999999990009999 00000000000000eCAM JNNNN 000000000000100000000000NN00000100NNCC J000CHF N000099999000 0000NNNANFRAGE STK NNNNN000000000000
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"ref": "223224",
|
||||
"wamas_code": "PE/PP/RO",
|
||||
"priority_sequence": 0,
|
||||
"game_identifier": "N",
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
ODOO WAMAS 00000120231221051251KSTAUS050000223224 PE/PP/RO kMEZ 0 N
|
||||
ODOO WAMAS 00000220231221051251KSTAUS050000223224 PE/PP/RO kPAR 0 N
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
{
|
||||
"ref": "113",
|
||||
"delivery_name": "Adam Smith",
|
||||
"delivery_name2": "Delivery Name 2",
|
||||
"delivery_name3": "Delivery Name 3",
|
||||
"delivery_name4": "Delivery Name 4",
|
||||
"delivery_title": "Delivery Title",
|
||||
"delivery_street": "3273 Laurel Lane",
|
||||
"delivery_street2": "",
|
||||
"delivery_zip": "79782",
|
||||
"delivery_city": "Sand Springs",
|
||||
"delivery_state": "Texas",
|
||||
"delivery_country_code": "US",
|
||||
"delivery_phone": "432-393-1264",
|
||||
"delivery_email": "aaa",
|
||||
"delivery_street": "adam@dayrep.com",
|
||||
"invoicing_name": "Adam Smith",
|
||||
"invoicing_name2": "Invoicing Name 2",
|
||||
"invoicing_name3": "Invoicing Name 3",
|
||||
"invoicing_name4": "Invoicing Name 4",
|
||||
"invoicing_title": "invoicing Title",
|
||||
"invoicing_street": "3273 Laurel Lane",
|
||||
"invoicing_street2": "",
|
||||
"invoicing_zip": "79782",
|
||||
"invoicing_city": "Sand Springs",
|
||||
"invoicing_state": "Texas",
|
||||
"invoicing_country_code": "US",
|
||||
"invoicing_phone": "432-393-1264",
|
||||
"invoicing_email": "aaa",
|
||||
"invoicing_street": "adam@dayrep.com",
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
ODOO WAMAS 00000120231221051251KST000052000113 Adam Smith Delivery Name 2 Delivery Name 3 Delivery Name 4 Delivery Title adam@dayrep.com 79782 Sand Springs Texas US 432-393-1264 aaa Adam Smith Invoicing Name 2 Invoicing Name 3 Invoicing Name 4 invoicing Titleadam@dayrep.com 79782 Sand Springs Texas US 432-393-1264 aaa 000000Standard JNNNJJNJJN0000 0Standard NNJN N
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"ref": "0001",
|
||||
"name": "Adam Smith",
|
||||
"name2": "Name 2",
|
||||
"name3": "Name 3",
|
||||
"name4": "Name 4",
|
||||
"street": "3273 Laurel Lane",
|
||||
"street2": "",
|
||||
"zip": "79782",
|
||||
"city": "Sand Springs",
|
||||
"state": "Texas",
|
||||
"country_code": "US",
|
||||
"phone": "432-393-1264",
|
||||
"email": "aaa",
|
||||
"website": "https://testing.com",
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
ODOO WAMAS 00000120231221051251LST0000510000001 Adam Smith Name 2 Name 3 Name 4 3273 Laurel Lane 79782 Sand Springs Texas US 432-393-1264 aaa https://testing.com Standard 0N JStandard N
|
||||
|
|
@ -0,0 +1,173 @@
|
|||
# Copyright 2023 Jacques-Etienne Baudoux (BCIM) <je@bcim.be>
|
||||
# Copyright 2023 Camptocamp SA
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from ast import literal_eval
|
||||
from base64 import b64decode, b64encode
|
||||
|
||||
from freezegun import freeze_time
|
||||
|
||||
from odoo.tests.common import TransactionCase
|
||||
from odoo.tools import file_open
|
||||
|
||||
from odoo.addons.account.tests.common import AccountTestInvoicingCommon
|
||||
|
||||
# FIXME: all simple convertion tests should move to lib/wamas/tests and there
|
||||
# should be a test that runs the lib tests
|
||||
|
||||
|
||||
class TestBaseWamas(TransactionCase):
|
||||
|
||||
maxDiff = None
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
cls.base_wamas_ubl = cls.env["base.wamas.ubl"]
|
||||
cls.wamas_ubl_wiz_check = cls.env["wamas.ubl.wiz.check"]
|
||||
cls.wamas_ubl_wiz_simulate = cls.env["wamas.ubl.wiz.simulate"]
|
||||
cls.assertXmlTreeEqual = AccountTestInvoicingCommon.assertXmlTreeEqual
|
||||
cls.get_xml_tree_from_string = (
|
||||
AccountTestInvoicingCommon.get_xml_tree_from_string
|
||||
)
|
||||
cls._turn_node_as_dict_hierarchy = (
|
||||
AccountTestInvoicingCommon._turn_node_as_dict_hierarchy
|
||||
)
|
||||
cls.partner_1 = cls.env.ref("base.res_partner_1")
|
||||
cls.partner_2 = cls.env.ref("base.res_partner_2")
|
||||
country_code_1 = cls.partner_1.commercial_partner_id.country_id.code or ""
|
||||
country_code_2 = cls.partner_2.commercial_partner_id.country_id.code or ""
|
||||
cls.extra_data = {
|
||||
"DespatchSupplierParty": {
|
||||
"CustomerAssignedAccountID": cls.partner_1.commercial_partner_id.ref
|
||||
or "",
|
||||
"PartyName": cls.partner_1.commercial_partner_id.name or "",
|
||||
"StreetName": cls.partner_1.commercial_partner_id.street or "",
|
||||
"CityName": cls.partner_1.commercial_partner_id.city or "",
|
||||
"PostalZone": cls.partner_1.commercial_partner_id.zip or "",
|
||||
"Country.IdentificationCode": country_code_1,
|
||||
"CompanyID": cls.partner_1.commercial_partner_id.vat or "",
|
||||
"TaxScheme.ID": "",
|
||||
"TaxScheme.TaxTypeCode": "",
|
||||
"Contact.Name": cls.partner_1.child_ids
|
||||
and cls.partner_1.child_ids[0].name
|
||||
or "",
|
||||
"Contact.Telephone": cls.partner_1.child_ids
|
||||
and cls.partner_1.child_ids[0].phone
|
||||
or "",
|
||||
"Contact.ElectronicMail": cls.partner_1.child_ids
|
||||
and cls.partner_1.child_ids[0].email
|
||||
or "",
|
||||
},
|
||||
"DeliveryCustomerParty": {
|
||||
"PartyName": cls.partner_2.commercial_partner_id.name or "",
|
||||
"StreetName": cls.partner_2.commercial_partner_id.street or "",
|
||||
"CityName": cls.partner_2.commercial_partner_id.city or "",
|
||||
"PostalZone": cls.partner_2.commercial_partner_id.zip or "",
|
||||
"CountrySubentity": cls.partner_2.commercial_partner_id.state_id.name
|
||||
or "",
|
||||
"Country.IdentificationCode": country_code_2,
|
||||
"CompanyID": cls.partner_2.commercial_partner_id.vat or "",
|
||||
"TaxScheme.ID": "",
|
||||
"TaxScheme.TaxTypeCode": "",
|
||||
"Contact.Name": cls.partner_2.child_ids
|
||||
and cls.partner_2.child_ids[0].name
|
||||
or "",
|
||||
"Contact.Telephone": cls.partner_2.child_ids
|
||||
and cls.partner_2.child_ids[0].phone
|
||||
or "",
|
||||
"Contact.Telefax": "",
|
||||
"Contact.ElectronicMail": cls.partner_2.child_ids
|
||||
and cls.partner_2.child_ids[0].email
|
||||
or "",
|
||||
},
|
||||
}
|
||||
|
||||
@freeze_time("2023-05-01")
|
||||
def _wamas_ubl_wiz_check(self, input_filename, expected_output_filename):
|
||||
with file_open(input_filename) as inputfile, file_open(
|
||||
expected_output_filename
|
||||
) as outputfile:
|
||||
str_input = inputfile.read()
|
||||
str_expected_output = outputfile.read().strip("\n")
|
||||
wizard = self.wamas_ubl_wiz_check.create(
|
||||
{
|
||||
"wamas_file": b64encode(str_input.encode("iso-8859-1")),
|
||||
}
|
||||
)
|
||||
wizard._onchange_wamas_filename()
|
||||
self.assertFalse(wizard.output)
|
||||
wizard.btn_check()
|
||||
self.assertEqual(wizard.output, str_expected_output)
|
||||
|
||||
@freeze_time("2023-05-01 00:00:00")
|
||||
def _wamas_ubl_wiz_simulate(
|
||||
self, input_filename, expected_output_filename, state="success"
|
||||
):
|
||||
with file_open(input_filename) as inputfile, file_open(
|
||||
expected_output_filename
|
||||
) as outputfile:
|
||||
str_input = inputfile.read()
|
||||
expected_output = outputfile.read()
|
||||
wizard = self.wamas_ubl_wiz_simulate.create(
|
||||
{
|
||||
"wamas_file": b64encode(str_input.encode("iso-8859-1")),
|
||||
}
|
||||
)
|
||||
wizard._onchange_wamas_filename()
|
||||
self.assertFalse(wizard.output_wamas_file)
|
||||
self.assertFalse(wizard.output_wamas_filename)
|
||||
self.assertFalse(wizard.output)
|
||||
wizard.btn_simulate()
|
||||
if state == "success":
|
||||
output = b64decode(wizard.output_wamas_file).decode("iso-8859-1")
|
||||
self.assertEqual(output, expected_output)
|
||||
else:
|
||||
self.assertEqual(wizard.output, expected_output)
|
||||
|
||||
def test_wamas_ubl_wiz_check(self):
|
||||
# Success
|
||||
self._wamas_ubl_wiz_check(
|
||||
"base_wamas_ubl/tests/samples/CHECKWAMAS-SAMPLE_INPUT.wamas",
|
||||
"base_wamas_ubl/tests/samples/CHECKWAMAS-SAMPLE_OUTPUT.txt",
|
||||
)
|
||||
|
||||
def test_wamas_ubl_wiz_check_exception_1(self):
|
||||
# Raise Exception
|
||||
self._wamas_ubl_wiz_check(
|
||||
"base_wamas_ubl/tests/samples/CHECKWAMAS-SAMPLE_INPUT-EXCEPTION.wamas",
|
||||
"base_wamas_ubl/tests/samples/CHECKWAMAS-SAMPLE_OUTPUT-EXCEPTION.txt",
|
||||
)
|
||||
|
||||
def test_wamas_ubl_wiz_check_exception_2(self):
|
||||
self._wamas_ubl_wiz_check(
|
||||
"base_wamas_ubl/tests/samples/CHECKWAMAS-SAMPLE_INPUT-EXCEPTION-2.wamas",
|
||||
"base_wamas_ubl/tests/samples/CHECKWAMAS-SAMPLE_OUTPUT-EXCEPTION-2.txt",
|
||||
)
|
||||
|
||||
def test_wamas_ubl_wiz_simulate(self):
|
||||
# Success
|
||||
self._wamas_ubl_wiz_simulate(
|
||||
"base_wamas_ubl/tests/samples/SIMULATEWAMAS-SAMPLE_INPUT.wamas",
|
||||
"base_wamas_ubl/tests/samples/SIMULATEWAMAS-SAMPLE_OUTPUT.wamas",
|
||||
)
|
||||
# Raise Exception
|
||||
self._wamas_ubl_wiz_simulate(
|
||||
"base_wamas_ubl/tests/samples/SIMULATEWAMAS-SAMPLE_INPUT-EXCEPTION.wamas",
|
||||
"base_wamas_ubl/tests/samples/SIMULATEWAMAS-SAMPLE_OUTPUT-EXCEPTION.txt",
|
||||
"fail",
|
||||
)
|
||||
|
||||
@freeze_time("2023-12-21 04:12:51")
|
||||
def test_get_wamas_type(self):
|
||||
input_filename = "CHECKWAMAS-SAMPLE_INPUT.wamas"
|
||||
expected_output_filename = "CHECKWAMAS-SAMPLE_OUTPUT.dict"
|
||||
path = "base_wamas_ubl/tests/samples/"
|
||||
with file_open(path + input_filename) as inputfile, file_open(
|
||||
path + expected_output_filename
|
||||
) as outputfile:
|
||||
str_input = inputfile.read()
|
||||
dict_expected_output = literal_eval(outputfile.read())
|
||||
wamas_type = self.base_wamas_ubl.get_wamas_type(str_input)
|
||||
# Wamas Type
|
||||
self.assertEqual(wamas_type, dict_expected_output["wamas_type"])
|
||||
|
|
@ -0,0 +1,101 @@
|
|||
# Copyright 2024 Jacques-Etienne Baudoux (BCIM) <je@bcim.be>
|
||||
# Copyright 2024 Camptocamp SA
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from ast import literal_eval
|
||||
|
||||
from freezegun import freeze_time
|
||||
|
||||
from odoo.tests import common
|
||||
from odoo.tools import file_open
|
||||
|
||||
|
||||
class TestRecordToWAMAS(common.TransactionCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
cls.base_wamas_ubl = cls.env["base.wamas.ubl"]
|
||||
|
||||
def test_export_without_telegram(self):
|
||||
with self.assertRaisesRegex(
|
||||
ValueError, r"Please define wamas message type \(msg_type\)."
|
||||
):
|
||||
input_dict = {"name": "David", "age": 16}
|
||||
self.env["base.wamas.ubl"].record_data_to_wamas(input_dict, "")
|
||||
|
||||
def test_export_invalid_dict(self):
|
||||
with self.assertRaisesRegex(ValueError, "The data is not valid."):
|
||||
input_dict = ["David", 16]
|
||||
self.base_wamas_ubl.record_data_to_wamas(input_dict, "Supplier")
|
||||
|
||||
@freeze_time("2023-12-21 04:12:51")
|
||||
def test_export_with_LST_telegram(self):
|
||||
dict_data = {
|
||||
"input": "base_wamas_ubl/tests/samples/TELEGRAM-SAMPLE-LST_INPUT.dict",
|
||||
"expected_output": "base_wamas_ubl/tests/samples/TELEGRAM-SAMPLE-LST_OUTPUT.wamas",
|
||||
}
|
||||
expected_output = file_open(dict_data["expected_output"], "r").read()
|
||||
dict_input = literal_eval(file_open(dict_data["input"], "r").read())
|
||||
output = self.base_wamas_ubl.record_data_to_wamas(dict_input, "Supplier")
|
||||
self.assertEqual(output, expected_output)
|
||||
|
||||
@freeze_time("2023-12-21 04:12:51")
|
||||
def test_export_with_KST_telegram(self):
|
||||
dict_data = {
|
||||
"input": "base_wamas_ubl/tests/samples/TELEGRAM-SAMPLE-KST_INPUT.dict",
|
||||
"expected_output": "base_wamas_ubl/tests/samples/TELEGRAM-SAMPLE-KST_OUTPUT.wamas",
|
||||
}
|
||||
expected_output = file_open(dict_data["expected_output"], "r").read()
|
||||
dict_input = literal_eval(file_open(dict_data["input"], "r").read())
|
||||
output = self.base_wamas_ubl.record_data_to_wamas(dict_input, "Customer")
|
||||
self.assertEqual(output, expected_output)
|
||||
|
||||
@freeze_time("2023-12-21 04:12:51")
|
||||
def test_export_with_ART_telegram(self):
|
||||
dict_data = {
|
||||
"input": "base_wamas_ubl/tests/samples/TELEGRAM-SAMPLE-ART_INPUT.dict",
|
||||
"expected_output": "base_wamas_ubl/tests/samples/TELEGRAM-SAMPLE-ART_OUTPUT.wamas",
|
||||
}
|
||||
expected_output = (
|
||||
file_open(dict_data["expected_output"], "r").read().strip("\n")
|
||||
)
|
||||
dict_input = literal_eval(file_open(dict_data["input"], "r").read())
|
||||
output = self.base_wamas_ubl.record_data_to_wamas(dict_input, "Product")
|
||||
self.assertEqual(output, expected_output)
|
||||
|
||||
@freeze_time("2023-12-21 04:12:51")
|
||||
def test_export_with_ARTE_telegram(self):
|
||||
dict_data = {
|
||||
"input": "base_wamas_ubl/tests/samples/TELEGRAM-SAMPLE-ARTE_INPUT.dict",
|
||||
"expected_output": "base_wamas_ubl/tests/samples/TELEGRAM-SAMPLE-ARTE_OUTPUT.wamas",
|
||||
}
|
||||
expected_output = file_open(dict_data["expected_output"], "r").read()
|
||||
dict_input = literal_eval(file_open(dict_data["input"], "r").read())
|
||||
output = self.base_wamas_ubl.record_data_to_wamas(dict_input, "Packaging")
|
||||
self.assertEqual(output, expected_output)
|
||||
|
||||
@freeze_time("2023-12-21 04:12:51")
|
||||
def test_export_with_ARTEAN_telegram(self):
|
||||
dict_data = {
|
||||
"input": "base_wamas_ubl/tests/samples/TELEGRAM-SAMPLE-ARTEAN_INPUT.dict",
|
||||
"expected_output": "base_wamas_ubl/tests/samples/TELEGRAM-SAMPLE-ARTEAN_OUTPUT"
|
||||
".wamas",
|
||||
}
|
||||
expected_output = file_open(dict_data["expected_output"], "r").read()
|
||||
dict_input = literal_eval(file_open(dict_data["input"], "r").read())
|
||||
output = self.base_wamas_ubl.record_data_to_wamas(dict_input, "Barcode")
|
||||
self.assertEqual(output, expected_output)
|
||||
|
||||
@freeze_time("2023-12-21 04:12:51")
|
||||
def test_export_with_KSTAUS_telegram(self):
|
||||
dict_data = {
|
||||
"input": "base_wamas_ubl/tests/samples/TELEGRAM-SAMPLE-KSTAUS_INPUT.dict",
|
||||
"expected_output": "base_wamas_ubl/tests/samples/TELEGRAM-SAMPLE-KSTAUS_OUTPUT"
|
||||
".wamas",
|
||||
}
|
||||
expected_output = file_open(dict_data["expected_output"], "r").read()
|
||||
dict_input = literal_eval(file_open(dict_data["input"], "r").read())
|
||||
output = self.base_wamas_ubl.record_data_to_wamas(
|
||||
dict_input, "CustomerDeliveryPreferences"
|
||||
)
|
||||
self.assertEqual(output, expected_output)
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
# Copyright 2023 Jacques-Etienne Baudoux (BCIM) <je@bcim.be>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from ..lib.wamas.tests.test_dict2wamas import * # noqa: F401,F403
|
||||
from ..lib.wamas.tests.test_ubl2wamas import * # noqa: F401,F403
|
||||
from ..lib.wamas.tests.test_utils import * # noqa: F401,F403
|
||||
from ..lib.wamas.tests.test_wamas2dict import * # noqa: F401,F403
|
||||
from ..lib.wamas.tests.test_wamas2ubl import * # noqa: F401,F403
|
||||
from ..lib.wamas.tests.test_wamas2wamas import * # noqa: F401,F403
|
||||
Loading…
Add table
Add a link
Reference in a new issue