Use single shared remote command lock
This commit is contained in:
@@ -250,14 +250,16 @@ class TestRemoteDataFormat:
|
||||
"""Test untargeted duplicate remote commands only run in one process."""
|
||||
self.manager.initialize(mock_environment)
|
||||
lock_path = tmp_path / "remote-command.lock"
|
||||
lock_path.write_text("999999 1\n")
|
||||
event_data = "command say duplicated"
|
||||
event_hash = self.manager._get_remote_command_hash(event_data)
|
||||
lock_path.write_text(f"999999 {event_hash} {time.time()}\n")
|
||||
|
||||
with patch.object(
|
||||
self.manager,
|
||||
"_get_remote_command_lock_path",
|
||||
return_value=str(lock_path),
|
||||
):
|
||||
self.manager.handle_remote_incomming("command say duplicated")
|
||||
self.manager.handle_remote_incomming(event_data)
|
||||
|
||||
mock_environment["runtime"]["OutputManager"].speak_text.assert_not_called()
|
||||
|
||||
@@ -278,6 +280,24 @@ class TestRemoteDataFormat:
|
||||
|
||||
assert mock_environment["runtime"]["OutputManager"].speak_text.call_count == 2
|
||||
|
||||
def test_remote_incoming_allows_different_command_after_claim(
|
||||
self, mock_environment, tmp_path
|
||||
):
|
||||
"""Test a fresh different command is not suppressed by the shared lock."""
|
||||
self.manager.initialize(mock_environment)
|
||||
lock_path = tmp_path / "remote-command.lock"
|
||||
previous_hash = self.manager._get_remote_command_hash("command say first")
|
||||
lock_path.write_text(f"999999 {previous_hash} {time.time()}\n")
|
||||
|
||||
with patch.object(
|
||||
self.manager,
|
||||
"_get_remote_command_lock_path",
|
||||
return_value=str(lock_path),
|
||||
):
|
||||
self.manager.handle_remote_incomming("command say second")
|
||||
|
||||
mock_environment["runtime"]["OutputManager"].speak_text.assert_called_once()
|
||||
|
||||
|
||||
@pytest.mark.integration
|
||||
@pytest.mark.remote
|
||||
|
||||
Reference in New Issue
Block a user