From 3185210f3eb6834d818dc99611b305111f5387a8 Mon Sep 17 00:00:00 2001 From: gary Date: Sun, 6 Aug 2023 20:15:34 +0200 Subject: [PATCH] finished rework of class GatewayApiTestCase() --- bin/user/tests/test_egd.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/bin/user/tests/test_egd.py b/bin/user/tests/test_egd.py index 5d62f14..70c1dd1 100644 --- a/bin/user/tests/test_egd.py +++ b/bin/user/tests/test_egd.py @@ -1226,7 +1226,6 @@ class GatewayApiTestCase(unittest.TestCase): # API command code (byte) for CMD_READ_FIRMWARE_VERSION, used for various # tests that require an issuing an API command cmd_read_fware_code_byte = b'\x50' - read_fware_cmd_bytes = b'\xff\xffP\x03S' # known good read firmware (CMD_READ_FIRMWARE_VERSION) response bytes read_fware_resp_bytes = b'\xff\xffP\x11\rGW1000_V1.6.1v' # read firmware (CMD_READ_FIRMWARE_VERSION) response bytes with a bad @@ -1625,13 +1624,20 @@ def test_rediscovery(self, mock_get_mac, mock_get_firmware, mock_get_system_para Checks gw1000.GatewayApi.rediscover correctly rediscovers devices. This is performed using the following test elements: - 1. check that gw1000.GatewayApi.rediscover() correctly rediscovers a previously discovered device - 2. check that gw1000.GatewayApi.rediscover() raises an - InvalidChecksum exception when validating an API response with an - invalid checksum - 3. check that gw1000.GatewayApi.check_response() raises an - UnknownApiCommand exception when validating an API response with a - valid checksum but with an unexpected command code + 1. check that gw1000.GatewayApi.rediscover() correctly rediscovers a + previously discovered device with the same IP address and port + 2. check that gw1000.GatewayApi.rediscover() correctly rediscovers a + previously discovered device with a different IP address and port + 3. check that gw1000.GatewayApi.rediscover() correctly handles the + situation where multiple devices are discovered but does not include + the previously discovered device + 4. check that gw1000.GatewayApi.rediscover() correctly handles the + situation where no devices are discovered + 5. check that gw1000.GatewayApi.rediscover() correctly handles the + situation when gw1000.GatewayApi.discover() raises a socket.error + 6. check that gw1000.GatewayApi.rediscover() correctly handles the + situation when gw1000.GatewayApi.discover() raises a + user.gw1000.UnknonwApiCommand exception This test uses mocked return values from various gw1000.GatewayApi methods to allow the test to be run without a physical gateway device.