From 170cb736cba344713fc609132b472d20074155f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20K=C3=A1rolyi?= Date: Sun, 22 Apr 2018 17:35:27 +0200 Subject: [PATCH] Fixing tests --- ecrterm/ecr.py | 6 +++--- ecrterm/packets/apdu.py | 6 +++--- ecrterm/packets/base_packets.py | 8 ++++---- ecrterm/tests/test_data_encoding.py | 19 +++++++++---------- 4 files changed, 19 insertions(+), 20 deletions(-) diff --git a/ecrterm/ecr.py b/ecrterm/ecr.py index f852c8e..a3db0e8 100644 --- a/ecrterm/ecr.py +++ b/ecrterm/ecr.py @@ -15,8 +15,8 @@ from ecrterm.conv import bs2hl, toBytes, toHexString from ecrterm.exceptions import TransportLayerException from ecrterm.packets.apdu import Packets from ecrterm.packets.base_packets import ( - Authorisation, Completion, EndOfDay, Packet, PrintLine, Registration, - ResetTerminal, ShowText, StatusEnquiry, StatusInformation) + Authorisation, Completion, DisplayText, EndOfDay, Packet, PrintLine, + Registration, ResetTerminal, StatusEnquiry, StatusInformation) from ecrterm.packets.bmp import BCD from ecrterm.transmission.signals import ACK, DLE, ETX, NAK, STX, TRANSMIT_OK from ecrterm.utils import is_stringlike @@ -319,7 +319,7 @@ class ECR(object): for line in lines[:self.MAX_TEXT_LINES]: kw['line%s' % i] = line i += 1 - return self.transmit(ShowText(**kw)) + return self.transmit(DisplayText(**kw)) def status(self): """ diff --git a/ecrterm/packets/apdu.py b/ecrterm/packets/apdu.py index e2ede2b..883b5b0 100644 --- a/ecrterm/packets/apdu.py +++ b/ecrterm/packets/apdu.py @@ -241,9 +241,9 @@ class APDUPacket(object): if isinstance(blob, list): # allright. # first we detect our packetclass - Kls = Packets.detect(blob[:2]) - if Kls: - instance = Kls() + PacketClass = Packets.detect(blob[:2]) + if PacketClass: + instance = PacketClass() # fix for multipackets: if instance.cmd_instr is None: instance.cmd_instr = blob[1] diff --git a/ecrterm/packets/base_packets.py b/ecrterm/packets/base_packets.py index 7bb20f6..7fbcda3 100644 --- a/ecrterm/packets/base_packets.py +++ b/ecrterm/packets/base_packets.py @@ -252,7 +252,7 @@ Packets.register(Initialisation) # --- Text Related --- -class ShowText(Packet): +class DisplayText(Packet): """ 06 E0 chapters: bzt 3.2.26, pt 2.24 @@ -266,10 +266,10 @@ class ShowText(Packet): 'line6', 'line7', 'line8', 'beeps'] -Packets.register(ShowText) +Packets.register(DisplayText) -class ShowTextIntInput(Packet): +class DisplayTextIntInput(Packet): """ 06 E2 text output with numerical input. @@ -277,7 +277,7 @@ class ShowTextIntInput(Packet): cmd_instr = 0xe2 -Packets.register(ShowTextIntInput) +Packets.register(DisplayTextIntInput) class Completion(Packet): diff --git a/ecrterm/tests/test_data_encoding.py b/ecrterm/tests/test_data_encoding.py index 8300744..d6a98cd 100644 --- a/ecrterm/tests/test_data_encoding.py +++ b/ecrterm/tests/test_data_encoding.py @@ -17,9 +17,8 @@ from unittest import TestCase, main from ecrterm.conv import toHexString from ecrterm.packets.base_packets import ( - Authorisation, Diagnosis, Initialisation, PacketReceived, - PacketReceivedError, PrintLine, Registration, ResetTerminal, ShowText, - StatusEnquiry) + Authorisation, Diagnosis, DisplayText, Initialisation, PacketReceived, + PacketReceivedError, PrintLine, Registration, ResetTerminal, StatusEnquiry) from ecrterm.transmission.signals import ACK, NAK from ecrterm.transmission.transport_serial import SerialMessage @@ -94,15 +93,15 @@ class TestCaseDataEncoding(TestCase): def test_packet_showtext(self): data_expected = \ - '10 02 06 E0 25 F2 F1 F5 45 49 4E 47 45 42 45 4E 20 55 4E 44 20 ' \ - '4F 4B F1 F1 F6 46 41 48 52 45 52 4E 55 4D 4D 45 52 20 20 20 20 ' \ - '10 03 5A BA' - lines = ['FAHRERNUMMER ', 'EINGEBEN UND OK', ] + '10 02 06 E0 25 F1 F1 F6 46 41 48 52 45 52 4E 55 4D 4D 45 52 20 ' \ + '20 20 20 F2 F1 F5 45 49 4E 47 45 42 45 4E 20 55 4E 44 20 4F 4B ' \ + '10 03 DE CD' + lines = ['FAHRERNUMMER ', 'EINGEBEN UND OK'] + # FAHRERNUMMER: # F1 F1 F6 46 41 48 52 45 52 4E 55 4D 4D 45 52 20 20 20 20 - # //FAHRERNUMMER + # EINGEBEN UND OK: # F2 F1 F5 45 49 4E 47 45 42 45 4E 20 55 4E 44 20 4F 4B - # //EINGEBEN UND OK - pk = ShowText( + pk = DisplayText( # display_duration=0, line1=lines[0], # beeps=5,