From 1e64d7bea1d45d580e62cde661408d597ade4331 Mon Sep 17 00:00:00 2001 From: Luis Ubieda Date: Thu, 2 Jan 2025 16:19:43 -0500 Subject: [PATCH] samples: sensor:shell: test all channels Loop through all of the channels and make sure that each channel has an output. Changes in patch originally present in #72972. Signed-off-by: Yong Cong Sin Signed-off-by: Luis Ubieda --- .../sensor/sensor_shell/pytest/test_sensor_shell.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/samples/sensor/sensor_shell/pytest/test_sensor_shell.py b/samples/sensor/sensor_shell/pytest/test_sensor_shell.py index 7a01bec9978..9736b2e9eb8 100644 --- a/samples/sensor/sensor_shell/pytest/test_sensor_shell.py +++ b/samples/sensor/sensor_shell/pytest/test_sensor_shell.py @@ -21,16 +21,12 @@ def test_sensor_shell_info(shell: Shell): def test_sensor_shell_get(shell: Shell): logger.info('send "sensor get" command') - lines = shell.exec_command('sensor get sensor@0 voltage') - assert any(['channel type=31(voltage)' in line for line in lines]), 'expected response not found' - - lines = shell.exec_command('sensor get sensor@1 53') - assert any(['channel type=53(gauge_state_of_health)' in line for line in lines]), 'expected response not found' - # Channel should be the last one before 'all' (because 'all' doesn't print anything) so that the # for-loop in `parse_named_int()` will go through everything - lines = shell.exec_command('sensor get sensor@0 gauge_desired_charging_current') - assert any(['channel type=59(gauge_desired_charging_current)' in line for line in lines]), 'expected response not found' + for channel in range(59): + logger.info(f'channel {channel}') + lines = shell.exec_command(f'sensor get sensor@0 {channel}') + assert any([f'channel type={channel}' in line for line in lines]), 'expected response not found' logger.info('response is valid')