def test_input_below_range(bright): request = SetBackLed(bright) with pytest.raises(ValueError): request.tobytes()
def test_example_input(): expected = bytearray([0xFF, 0xFF, 0x02, 0x21, 0x00, 0x02, 0x10, 0xCA]) request = SetBackLed(16) assert request.tobytes() == expected
def test_valid_input(bright): expected = bytearray([0xFF, 0xFF, 0x02, 0x21, 0x00, 0x02, bright]) expected.append((sum(expected[2:]) & 0xFF) ^ 0xFF) request = SetBackLed(bright) assert request.tobytes() == expected