Skip to content

Commit d2c4726

Browse files
committed
add test
1 parent b095a8a commit d2c4726

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

tests/test_application.py

+36
Original file line numberDiff line numberDiff line change
@@ -597,3 +597,39 @@ async def test_move_network_to_channel(app):
597597

598598
assert len(app._api._queued_at.mock_calls) == 1
599599
app._api._queued_at.assert_any_call("SC", 1 << (26 - 11))
600+
601+
602+
async def test_energy_scan(app):
603+
async def mock_at_command(cmd, *args):
604+
if cmd == "ED":
605+
return b"\x0A\x0F\x14\x19\x1E\x23\x28\x2D\x32\x37\x3C\x41\x46\x4B\x50\x55"
606+
607+
return None
608+
609+
app._api._at_command = mock.MagicMock(
610+
spec=XBee._at_command, side_effect=mock_at_command
611+
)
612+
time_s = 300
613+
energy = await app.energy_scan(
614+
channels=[x for x in range(11, 27)], duration_exp=time_s, count=3
615+
)
616+
assert app._api._at_command.call_count == 3
617+
assert app._api._at_command.call_args_list[0][0][1] == time_s
618+
assert {k: round(v, 3) for k, v in energy.items()} == {
619+
11: 254.032,
620+
12: 253.153,
621+
13: 251.486,
622+
14: 248.352,
623+
15: 242.562,
624+
16: 232.193,
625+
17: 214.619,
626+
18: 187.443,
627+
19: 150.853,
628+
20: 109.797,
629+
21: 72.172,
630+
22: 43.571,
631+
23: 24.769,
632+
24: 13.56,
633+
25: 7.264,
634+
26: 3.844,
635+
}

0 commit comments

Comments
 (0)