From c572cdb0264d8c5f269e3397d646490eb42017d5 Mon Sep 17 00:00:00 2001 From: zariiii9003 <52598363+zariiii9003@users.noreply.github.com> Date: Fri, 29 Dec 2023 19:56:30 +0100 Subject: [PATCH] add test for bus creation with multiple channels --- test/test_vector.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/test_vector.py b/test/test_vector.py index 16a79c6d1..b531115fa 100644 --- a/test/test_vector.py +++ b/test/test_vector.py @@ -134,6 +134,32 @@ def test_bus_creation_channel_index() -> None: bus.shutdown() +@pytest.mark.skipif(not XLDRIVER_FOUND, reason="Vector XL API is unavailable") +def test_bus_creation_multiple_channels() -> None: + bus = can.Bus( + channel="0, 1", + bitrate=1_000_000, + serial=_find_virtual_can_serial(), + interface="vector", + ) + assert isinstance(bus, canlib.VectorBus) + assert bus.protocol == can.CanProtocol.CAN_20 + assert len(bus.channels) == 2 + assert bus.mask == 3 + + xl_channel_config_0 = _find_xl_channel_config( + serial=_find_virtual_can_serial(), channel=0 + ) + assert xl_channel_config_0.busParams.data.can.bitRate == 1_000_000 + + xl_channel_config_1 = _find_xl_channel_config( + serial=_find_virtual_can_serial(), channel=1 + ) + assert xl_channel_config_1.busParams.data.can.bitRate == 1_000_000 + + bus.shutdown() + + def test_bus_creation_bitrate_mocked(mock_xldriver) -> None: bus = can.Bus(channel=0, interface="vector", bitrate=200_000, _testing=True) assert isinstance(bus, canlib.VectorBus)