#!/usr/bin/env python3 """ Tests for ISO-20022 Parser """ import pytest import xml.etree.ElementTree as ET from parsers.iso20022_parser import ISO20022Parser @pytest.fixture def parser(): return ISO20022Parser() @pytest.fixture def sample_pacs008(): return """ MSG001 2024-01-01T00:00:00 1 INSTR001 E2E001 TX001 SEPA 1000.00 BANKUS33 Creditor Name Street 123 12345 City US US1234567890 Remittance information """ def test_parse_pacs008(parser, sample_pacs008): """Test parsing pacs.008 message""" result = parser.parse_pacs008(sample_pacs008) assert result['type'] == 'pacs.008' assert result['messageId'] == 'MSG001' assert result['currency'] == 'USD' assert result['amount'] == '1000.00' assert 'creditor' in result assert 'debtor' in result def test_detect_message_type(parser, sample_pacs008): """Test message type detection""" root = ET.fromstring(sample_pacs008) message_type = parser._detect_message_type(root) assert message_type == 'pacs.008' def test_extract_party(parser, sample_pacs008): """Test party extraction""" root = ET.fromstring(sample_pacs008) creditor = parser._extract_party(root, './/pacs:Cdtr') assert 'name' in creditor assert creditor['name'] == 'Creditor Name' def test_extract_account(parser, sample_pacs008): """Test account extraction""" root = ET.fromstring(sample_pacs008) account = parser._extract_account(root, './/pacs:CdtrAcct') assert 'id' in account if __name__ == '__main__': pytest.main([__file__])