From 9934afe0d047d3fd46a5d40afbb23a5585aa42f2 Mon Sep 17 00:00:00 2001 From: Benedikt Bleimhofer Date: Tue, 15 Oct 2024 09:21:35 +0200 Subject: [PATCH] add extended_error_code + bump version --- ecrterm/__init__.py | 2 +- ecrterm/packets/fields.py | 1 + ecrterm/tests/test_parsing_abort.py | 24 ++++++++++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 ecrterm/tests/test_parsing_abort.py diff --git a/ecrterm/__init__.py b/ecrterm/__init__.py index 887a342..52e9a85 100644 --- a/ecrterm/__init__.py +++ b/ecrterm/__init__.py @@ -1 +1 @@ -__version__ = '1.0.7' +__version__ = '1.0.8' diff --git a/ecrterm/packets/fields.py b/ecrterm/packets/fields.py index 567a84c..360c0c3 100644 --- a/ecrterm/packets/fields.py +++ b/ecrterm/packets/fields.py @@ -326,6 +326,7 @@ def __get__(self, instance, objtype=None) -> TLV: 0x1f00: BEIntField(name='file_size', length=4), 0x1f10: FlagByteField(name="cardholder_identification", data_type=CardholderIdentification), 0x1f11: FlagByteField(name='online_tag', data_type=OnlineTag), + 0x1F16: BCDVariableLengthField(name="extended_error_code"), 0x1F17: StringField(name="extended_error_text", character_set=CharacterSet.ZVT_8BIT), 0x1F40: StringField(name="device_name", character_set=CharacterSet.ASCII_7BIT), 0x1F41: StringField(name="software_version", character_set=CharacterSet.ASCII_7BIT), diff --git a/ecrterm/tests/test_parsing_abort.py b/ecrterm/tests/test_parsing_abort.py new file mode 100644 index 0000000..6c21850 --- /dev/null +++ b/ecrterm/tests/test_parsing_abort.py @@ -0,0 +1,24 @@ +from unittest import TestCase, main + +from ecrterm.ecr import parse_represented_data +from ecrterm.packets.base_packets import Abort + + +class TestParsingAbort(TestCase): + + def test_abort_by_external_command(self): + packet = '061e2e6c062b1f1605ff000014411f1720416262727563682064757263682065787465726e6573204b6f6d6d616e646f21' + parsed = parse_represented_data(packet) + + print(parsed) + + self.assertIsInstance(parsed, Abort) + self.assertEqual(108, parsed.result_code) + tlv = parsed.get('tlv') + self.assertIsNotNone(tlv) + extended_error_code = tlv.get_value('extended_error_code') + self.assertEqual('ff00001441', extended_error_code) + + +if __name__ == '__main__': + main()