1
0

test_received_packet.py 784 B

123456789101112131415161718192021222324252627282930313233343536
  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. payload=b"\0",
  18. rssi_index=rssi_index,
  19. checksum_valid=True,
  20. link_quality_indicator=0,
  21. )
  22. assert packet.rssi_dbm == pytest.approx(rssi_dbm)
  23. def test___str__():
  24. packet = cc1101._ReceivedPacket(
  25. payload=b"\0\x12\x34",
  26. rssi_index=204,
  27. checksum_valid=True,
  28. link_quality_indicator=0,
  29. )
  30. assert str(packet) == "_ReceivedPacket(RSSI -100dBm, 0x001234)"