123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- import pytest
- @pytest.mark.parametrize(
- "patable",
- (
- (198, 0, 0, 0, 0, 0, 0, 0),
- (0, 198, 0, 0, 0, 0, 0, 0),
- (1, 2, 3, 4, 5, 6, 7, 8),
- ),
- )
- def test__get_patable(transceiver, patable):
- transceiver._spi.xfer.return_value = [0] + list(patable)
- assert transceiver._get_patable() == patable
- transceiver._spi.xfer.assert_called_once_with([0x3E | 0xC0] + [0] * 8)
- @pytest.mark.parametrize(
- "patable",
- (
- (198, 0, 0, 0, 0, 0, 0, 0),
- [198, 0, 0, 0, 0, 0, 0, 0],
- (0, 198, 0, 0, 0, 0, 0, 0),
- (1, 2, 3, 4, 5, 6, 7, 8),
- (1, 2, 3),
- (1,),
- ),
- )
- def test__set_patable(transceiver, patable):
- transceiver._spi.xfer.return_value = [0b00000111] * (len(patable) + 1)
- transceiver._set_patable(patable)
- transceiver._spi.xfer.assert_called_once_with([0x3E | 0x40] + list(patable))
- @pytest.mark.parametrize(
- "patable", ((21, -7), (0, 42, 256), (0, 1, 2, 3, 4, 5, 6, 7, 8))
- )
- def test__set_patable_invalid(transceiver, patable):
- with pytest.raises(Exception):
- transceiver._set_patable(patable)
- transceiver._spi.xfer.assert_not_called()
|