Skip to content

Commit

Permalink
samples: sensor:shell: test all channels
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Luis Ubieda <[email protected]>
(cherry picked from commit 1e64d7b)
  • Loading branch information
ubieda authored and github-actions[bot] committed Jan 9, 2025
1 parent 334ea8e commit 4810405
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions samples/sensor/sensor_shell/pytest/test_sensor_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down

0 comments on commit 4810405

Please sign in to comment.