test_str.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import unittest.mock
  2. import cc1101
  3. def test___str___():
  4. transceiver = cc1101.CC1101()
  5. with unittest.mock.patch.object(
  6. transceiver,
  7. "get_main_radio_control_state_machine_state",
  8. return_value=cc1101.MainRadioControlStateMachineState.IDLE,
  9. ), unittest.mock.patch.object(
  10. transceiver, "get_base_frequency_hertz", return_value=433.92e6
  11. ), unittest.mock.patch.object(
  12. transceiver, "get_symbol_rate_baud", return_value=2142
  13. ), unittest.mock.patch.object(
  14. transceiver,
  15. "get_modulation_format",
  16. return_value=cc1101.ModulationFormat.ASK_OOK,
  17. ), unittest.mock.patch.object(
  18. transceiver,
  19. "get_sync_mode",
  20. return_value=cc1101.SyncMode.NO_PREAMBLE_AND_SYNC_WORD,
  21. ), unittest.mock.patch.object(
  22. transceiver,
  23. "get_packet_length_mode",
  24. return_value=cc1101.PacketLengthMode.FIXED,
  25. ), unittest.mock.patch.object(
  26. transceiver, "get_packet_length_bytes", return_value=21
  27. ), unittest.mock.patch.object(
  28. transceiver, "get_output_power", return_value=(0, 0xC0)
  29. ):
  30. assert (
  31. str(transceiver) == "CC1101(marcstate=idle, base_frequency=433.92MHz, "
  32. "symbol_rate=2.14kBaud, modulation_format=ASK_OOK, "
  33. "sync_mode=NO_PREAMBLE_AND_SYNC_WORD, packet_length=21B, output_power=(0,0xc0))"
  34. )