test_received_packet.py 753 B

123456789101112131415161718192021222324252627282930313233
  1. import pytest
  2. import cc1101
  3. # pylint: disable=protected-access
  4. @pytest.mark.parametrize(
  5. ("rssi_index", "rssi_dbm"),
  6. [
  7. (128, -64 - 74),
  8. (204, -100),
  9. (255, -0.5 - 74),
  10. (0, -74),
  11. (64, 32 - 74),
  12. (127, 63.5 - 74),
  13. ],
  14. )
  15. def test_rss_dbm(rssi_index, rssi_dbm):
  16. packet = cc1101._ReceivedPacket(
  17. data=b"\0", rssi_index=rssi_index, checksum_valid=True, link_quality_indicator=0
  18. )
  19. assert packet.rssi_dbm == pytest.approx(rssi_dbm)
  20. def test___str__():
  21. packet = cc1101._ReceivedPacket(
  22. data=b"\0\x12\x34",
  23. rssi_index=204,
  24. checksum_valid=True,
  25. link_quality_indicator=0,
  26. )
  27. assert str(packet) == "_ReceivedPacket(RSSI -100dBm, 0x001234)"