Skip to content

Commit

Permalink
test(pain001): ✅ add new tests for create_xml_v4.py, `create_xml_v5…
Browse files Browse the repository at this point in the history
….py, etc.
  • Loading branch information
sebastienrousseau committed May 19, 2024
1 parent 603083f commit 817628f
Showing 1 changed file with 327 additions and 0 deletions.
327 changes: 327 additions & 0 deletions tests/test_generate_xml.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import unittest
import xml.etree.ElementTree as ET
from pain001.xml.create_xml_v3 import create_xml_v3
from pain001.xml.create_xml_v4 import create_xml_v4
from pain001.xml.create_xml_v5 import create_xml_v5
from pain001.xml.create_xml_v6 import create_xml_v6
from pain001.xml.create_xml_v7 import create_xml_v7
from pain001.xml.create_xml_v8 import create_xml_v8
from pain001.xml.create_xml_v9 import create_xml_v9
from pain001.xml.create_common_elements import (
create_common_elements,
Expand Down Expand Up @@ -56,6 +61,227 @@ def setUp(self):
}
],
}
self.row_v4 = {
"id": "1",
"date": "2023-03-10T15:30:47.000Z",
"nb_of_txs": "2",
"initiator_name": "Initiator",
"initiator_street": "Street",
"initiator_building_number": "1",
"initiator_postal_code": "12345",
"initiator_town": "Town",
"initiator_country": "DE",
"payment_information_id": "PID123",
"payment_id": "PID123", # Added payment_id
"payment_method": "pain.001.001.04",
"batch_booking": "true",
"requested_execution_date": "2023-05-21",
"debtor_name": "Debtor",
"debtor_street": "Street",
"debtor_building_number": "1",
"debtor_postal_code": "12345",
"debtor_town": "Town",
"debtor_country": "DE",
"debtor_account_IBAN": "DE123456789",
"debtor_agent_BIC": "DEUTDEFF",
"charge_bearer": "SLEV",
"creditor_agent_BIC": "NOLADE21KIE",
"creditor_name": "Creditor",
"creditor_street": "Street",
"creditor_building_number": "1",
"creditor_postal_code": "12345",
"creditor_town": "Town",
"creditor_country": "DE",
"creditor_account_IBAN": "DE123456789",
"payment_instruction_id": "PID123",
"payment_end_to_end_id": "E2E123",
"payment_currency": "EUR",
"payment_amount": "1500",
"purpose_code": "GDDS",
"reference_number": "RF123",
"reference_date": "2023-03-10T15:30:47.000Z",
}
self.row_v5 = {
"id": "1",
"date": "2023-03-10T15:30:47.000Z",
"nb_of_txs": "2",
"ctrl_sum": "3000",
"initiator_name": "Initiator",
"initiator_street_name": "Street",
"initiator_building_number": "1",
"initiator_postal_code": "12345",
"initiator_town_name": "Town",
"initiator_country": "DE",
"ultimate_debtor_name": "Ultimate Debtor",
"service_level_code": "SEPA",
"payment_information_id": "PID123",
"payment_id": "PID123",
"payment_method": "pain.001.001.05",
"batch_booking": "true",
"requested_execution_date": "2023-05-21",
"debtor_name": "Debtor",
"debtor_street": "Street",
"debtor_building_number": "1",
"debtor_postal_code": "12345",
"debtor_town": "Town",
"debtor_country": "DE",
"debtor_account_IBAN": "DE123456789",
"debtor_agent_BIC": "DEUTDEFF",
"charge_bearer": "SLEV",
"payment_instruction_id": "PID123",
"payment_end_to_end_id": "E2E123",
"payment_currency": "EUR",
"payment_amount": "1500",
"creditor_name": "Creditor",
"creditor_street": "Street",
"creditor_building_number": "1",
"creditor_postal_code": "12345",
"creditor_town": "Town",
"creditor_country": "DE",
"creditor_account_IBAN": "DE123456789",
"creditor_agent_BICFI": "NOLADE21KIE",
"purpose_code": "GDDS",
"reference_number": "RF123",
"reference_date": "2023-03-10T15:30:47.000Z",
}
self.row_v6 = {
"id": "2",
"date": "2023-03-11T15:30:47.000Z",
"nb_of_txs": "3",
"ctrl_sum": "4500",
"initiator_name": "Initiator 6",
"initiator_street_name": "Street 6",
"initiator_building_number": "6",
"initiator_postal_code": "12346",
"initiator_town_name": "Town 6",
"initiator_country": "DE",
"ultimate_debtor_name": "Ultimate Debtor 6",
"service_level_code": "SEPA",
"payment_information_id": "PID123",
"payment_id": "PID123",
"payment_method": "pain.001.001.06",
"batch_booking": "true",
"requested_execution_date": "2023-06-21",
"debtor_name": "Debtor 6",
"debtor_street": "Street 6",
"debtor_building_number": "6",
"debtor_postal_code": "12346",
"debtor_town": "Town 6",
"debtor_country": "DE",
"debtor_account_IBAN": "DE123456780",
"debtor_agent_name": "Agent",
"debtor_agent_BIC": "DEUTDEFG",
"charge_bearer": "SLEV",
"payment_instruction_id": "PID123",
"payment_end_to_end_id": "E2E124",
"payment_currency": "USD",
"payment_amount": "1600",
"creditor_name": "Creditor 6",
"creditor_street": "Street 6",
"creditor_building_number": "6",
"creditor_postal_code": "12346",
"creditor_town": "Town 6",
"creditor_country": "DE",
"creditor_account_IBAN": "DE123456780",
"creditor_agent_BICFI": "NOLADE21KIF",
"creditor_agent_name": "Creditor Agent",
"purpose_code": "GDDS",
"reference_number": "RF124",
"reference_date": "2023-03-11T15:30:47.000Z",
}

self.row_v7 = {
"id": "3",
"date": "2023-03-12T15:30:47.000Z",
"nb_of_txs": "4",
"ctrl_sum": "6000",
"initiator_name": "Initiator 7",
"initiator_street_name": "Street 7",
"initiator_building_number": "7",
"initiator_postal_code": "12347",
"initiator_town_name": "Town 7",
"initiator_country": "DE",
"ultimate_debtor_name": "Ultimate Debtor 7",
"service_level_code": "SEPA",
"payment_information_id": "PID123",
"payment_id": "PID123",
"payment_method": "pain.001.001.07",
"batch_booking": "true",
"requested_execution_date": "2023-07-21",
"debtor_name": "Debtor 7",
"debtor_street": "Street 7",
"debtor_building_number": "7",
"debtor_postal_code": "12347",
"debtor_town": "Town 7",
"debtor_country": "DE",
"debtor_account_IBAN": "DE123456781",
"debtor_agent_name": "Agent",
"debtor_agent_BIC": "DEUTDEFH",
"charge_bearer": "SLEV",
"payment_instruction_id": "PID123",
"payment_end_to_end_id": "E2E125",
"payment_currency": "GBP",
"payment_amount": "1700",
"creditor_name": "Creditor 7",
"creditor_street": "Street 7",
"creditor_building_number": "7",
"creditor_postal_code": "12347",
"creditor_town": "Town 7",
"creditor_country": "DE",
"creditor_account_IBAN": "DE123456781",
"creditor_agent_BICFI": "NOLADE21KIG",
"creditor_agent_name": "Creditor Agent",
"purpose_code": "GDDS",
"reference_number": "RF125",
"reference_date": "2023-03-12T15:30:47.000Z",
}

self.row_v8 = {
"id": "4",
"date": "2023-03-13T15:30:47.000Z",
"nb_of_txs": "5",
"ctrl_sum": "7500",
"initiator_name": "Initiator 8",
"initiator_street_name": "Street 8",
"initiator_building_number": "8",
"initiator_postal_code": "12348",
"initiator_town_name": "Town 8",
"initiator_country": "DE",
"ultimate_debtor_name": "Ultimate Debtor 8",
"service_level_code": "SEPA",
"payment_information_id": "PID123",
"payment_id": "PID123",
"payment_method": "pain.001.001.08",
"batch_booking": "true",
"requested_execution_date": "2023-08-21",
"debtor_name": "Debtor 8",
"debtor_street": "Street 8",
"debtor_building_number": "8",
"debtor_postal_code": "12348",
"debtor_town": "Town 8",
"debtor_country": "DE",
"debtor_account_IBAN": "DE123456782",
"debtor_agent_name": "Agent",
"debtor_agent_BIC": "DEUTDEFH",
"charge_bearer": "SLEV",
"payment_instruction_id": "PID123",
"payment_end_to_end_id": "E2E126",
"payment_currency": "JPY",
"payment_amount": "1800",
"creditor_name": "Creditor 8",
"creditor_street": "Street 8",
"creditor_building_number": "8",
"creditor_postal_code": "12348",
"creditor_town": "Town 8",
"creditor_country": "DE",
"creditor_account_IBAN": "DE123456782",
"creditor_agent_name": "Creditor Agent",
"creditor_agent_BICFI": "NOLADE21KIH",
"purpose_code": "GDDS",
"reference_number": "RF126",
"reference_date": "2023-03-13T15:30:47.000Z",
}

self.row_v9 = {
"id": "1",
"date": "2023-03-10T15:30:47.000Z",
Expand Down Expand Up @@ -85,6 +311,7 @@ def setUp(self):
"payment_amount": "1500",
"payment_currency": "EUR",
"charge_bearer": "SLEV",
"creditor_agent_name": "Creditor Agent",
"creditor_agent_BIC": "NOLADE21KIE",
"creditor_name": "Creditor",
"creditor_street_name": "Street",
Expand Down Expand Up @@ -113,6 +340,11 @@ def generate_xml(self):
Generate XML using create_xml_v3
"""
create_xml_v3(self.root, [self.row_v3])
create_xml_v4(self.root, [self.row_v4])
create_xml_v5(self.root, [self.row_v5])
create_xml_v6(self.root, [self.row_v6])
create_xml_v7(self.root, [self.row_v7])
create_xml_v8(self.root, [self.row_v8])
create_xml_v9(self.root, [self.row_v9])

def test_create_common_elements_v3(self):
Expand All @@ -126,6 +358,61 @@ def test_create_common_elements_v3(self):
self.assertEqual(self.root[1].tag, "PmtMtd")
self.assertEqual(self.root[1].text, "pain.001.001.03")

def test_create_common_elements_v4(self):
"""
Test create_common_elements for version 4
"""
create_common_elements(self.root, self.row_v4, self.mapping)
self.assertEqual(len(self.root), 2)
self.assertEqual(self.root[0].tag, "PmtInfId")
self.assertEqual(self.root[0].text, "PID123")
self.assertEqual(self.root[1].tag, "PmtMtd")
self.assertEqual(self.root[1].text, "pain.001.001.04")

def test_create_common_elements_v5(self):
"""
Test create_common_elements for version 5
"""
create_common_elements(self.root, self.row_v5, self.mapping)
self.assertEqual(len(self.root), 2)
self.assertEqual(self.root[0].tag, "PmtInfId")
self.assertEqual(self.root[0].text, "PID123")
self.assertEqual(self.root[1].tag, "PmtMtd")
self.assertEqual(self.root[1].text, "pain.001.001.05")

def test_create_common_elements_v6(self):
"""
Test create_common_elements for version 6
"""
create_common_elements(self.root, self.row_v6, self.mapping)
self.assertEqual(len(self.root), 2)
self.assertEqual(self.root[0].tag, "PmtInfId")
self.assertEqual(self.root[0].text, "PID123")
self.assertEqual(self.root[1].tag, "PmtMtd")
self.assertEqual(self.root[1].text, "pain.001.001.06")

def test_create_common_elements_v7(self):
"""
Test create_common_elements for version 7
"""
create_common_elements(self.root, self.row_v7, self.mapping)
self.assertEqual(len(self.root), 2)
self.assertEqual(self.root[0].tag, "PmtInfId")
self.assertEqual(self.root[0].text, "PID123")
self.assertEqual(self.root[1].tag, "PmtMtd")
self.assertEqual(self.root[1].text, "pain.001.001.07")

def test_create_common_elements_v8(self):
"""
Test create_common_elements for version 8
"""
create_common_elements(self.root, self.row_v8, self.mapping)
self.assertEqual(len(self.root), 2)
self.assertEqual(self.root[0].tag, "PmtInfId")
self.assertEqual(self.root[0].text, "PID123")
self.assertEqual(self.root[1].tag, "PmtMtd")
self.assertEqual(self.root[1].text, "pain.001.001.08")

def test_create_common_elements_v9(self):
"""
Test create_common_elements for version 9
Expand All @@ -145,6 +432,46 @@ def test_create_xml_v3(self):
cstmr_cdt_trf_initn_element = self.root[0]
self.assertEqual(cstmr_cdt_trf_initn_element.tag, "CstmrCdtTrfInitn")

def test_create_xml_v4(self):
"""
Test create_xml_v4
"""
create_xml_v4(self.root, [self.row_v4])
cstmr_cdt_trf_initn_element = self.root[0]
self.assertEqual(cstmr_cdt_trf_initn_element.tag, "CstmrCdtTrfInitn")

def test_create_xml_v5(self):
"""
Test create_xml_v5
"""
create_xml_v5(self.root, [self.row_v5])
cstmr_cdt_trf_initn_element = self.root[0]
self.assertEqual(cstmr_cdt_trf_initn_element.tag, "CstmrCdtTrfInitn")

def test_create_xml_v6(self):
"""
Test create_xml_v6
"""
create_xml_v6(self.root, [self.row_v6])
cstmr_cdt_trf_initn_element = self.root[0]
self.assertEqual(cstmr_cdt_trf_initn_element.tag, "CstmrCdtTrfInitn")

def test_create_xml_v7(self):
"""
Test create_xml_v7
"""
create_xml_v7(self.root, [self.row_v7])
cstmr_cdt_trf_initn_element = self.root[0]
self.assertEqual(cstmr_cdt_trf_initn_element.tag, "CstmrCdtTrfInitn")

def test_create_xml_v8(self):
"""
Test create_xml_v8
"""
create_xml_v8(self.root, [self.row_v8])
cstmr_cdt_trf_initn_element = self.root[0]
self.assertEqual(cstmr_cdt_trf_initn_element.tag, "CstmrCdtTrfInitn")

def test_create_xml_v9(self):
"""
Test create_xml_v9
Expand Down

0 comments on commit 817628f

Please sign in to comment.