Files
StarPilot/openpilot/common/hardware/comma/tests/test_infrared.py
T
firestar5683 80fbb4f6db Feature registration
Register vehicle controls, planner modes, UI actions and Galaxy services after their providers exist. Wire the shared runtime entrypoints and cover their combined behavior.

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
Co-authored-by: Daniel Koepping <elkoled@gmail.com>
Co-authored-by: Danny <dannyirwin31@yahoo.com>
Co-authored-by: DimitriChrysafis <Dimitri.chrysafis@gmail.com>
Co-authored-by: Dom <168790843+firestar5683@users.noreply.github.com>
Co-authored-by: Harald Schäfer <harald.the.engineer@gmail.com>
Co-authored-by: Kacper Rączy <gfw.kra@gmail.com>
Co-authored-by: Prabhaav Pillai <prabhaav@msu.edu>
Co-authored-by: dirwin31 <83434411+dirwin31@users.noreply.github.com>
Co-authored-by: firestarsdog <229254897+firestarsdog@users.noreply.github.com>
Co-authored-by: stef <19478336+stefpi@users.noreply.github.com>
Co-authored-by: whoisdomi <dcantu83@gmail.com>

Co-authored-by: Intelli <contact@intelli.software>
Co-authored-by: haraschax <6804392+haraschax@users.noreply.github.com>
Co-authored-by: prabhaavp <prabhaav@msu.edu>
2026-10-14 20:02:39 -05:00

28 lines
980 B
Python

from unittest.mock import Mock, mock_open, patch
import pytest
from openpilot.common.hardware.comma.hardware import HardwareComma
@pytest.mark.parametrize('device', ['tici', 'tizi'])
def test_panda_owns_comma_three_infrared(device):
hardware = HardwareComma.__new__(HardwareComma)
hardware.get_device_type = Mock(return_value=device)
with patch('builtins.open') as opened:
hardware.set_ir_power(100)
opened.assert_not_called()
def test_comma_four_retains_soc_infrared():
hardware = HardwareComma.__new__(HardwareComma)
hardware.get_device_type = Mock(return_value='mici')
with patch('builtins.open', mock_open()) as opened:
hardware.set_ir_power(50)
assert [call.args[0] for call in opened.call_args_list] == [
'/sys/class/leds/led:switch_2/brightness',
'/sys/class/leds/led:torch_2/brightness',
'/sys/class/leds/led:switch_2/brightness',
]
assert [call.args[0] for call in opened().write.call_args_list] == ['0\n', '150\n', '150\n']