fix variation

This commit is contained in:
awe
2026-02-18 19:01:28 +03:00
parent 9b82077b64
commit 0b9eed566e
3 changed files with 57 additions and 10 deletions

View File

@ -239,15 +239,19 @@ class TestConnectionManagement:
assert "connect" in str(exc_info.value).lower()
def test_stop_task_sends_default_enable(self, connected_controller, mock_serial):
"""stop_task should send DEFAULT_ENABLE (0x2222)."""
"""stop_task should send DEFAULT_ENABLE (0x2222) first, then DECODE_ENABLE (0x1111)."""
mock_serial.write.reset_mock()
connected_controller.stop_task()
assert mock_serial.write.called
sent_data = mock_serial.write.call_args[0][0]
# DEFAULT_ENABLE: 0x2222 → flipped to bytes 0x22 0x22
assert sent_data[0] == 0x22
assert sent_data[1] == 0x22
assert mock_serial.write.call_count >= 2
# First call: DEFAULT_ENABLE 0x2222 → flipped bytes 0x22 0x22
first_call = mock_serial.write.call_args_list[0][0][0]
assert first_call[0] == 0x22
assert first_call[1] == 0x22
# Second call: DECODE_ENABLE 0x1111 → flipped bytes 0x11 0x11
second_call = mock_serial.write.call_args_list[1][0][0]
assert second_call[0] == 0x11
assert second_call[1] == 0x11
def test_reset_sends_default_enable(self, connected_controller, mock_serial):
"""reset() should also send DEFAULT_ENABLE."""