diff --git a/mopidy/utils/network.py b/mopidy/utils/network.py index 9306ccd7..50b7d239 100644 --- a/mopidy/utils/network.py +++ b/mopidy/utils/network.py @@ -161,7 +161,7 @@ class Connection(object): except socket.error: pass - def send(self, data): + def queue_send(self, data): """Send data to client exactly as is.""" self.send_lock.acquire(True) self.send_buffer += data @@ -383,4 +383,4 @@ class LineProtocol(ThreadingActor): return data = self.join_lines(lines) - self.connection.send(self.encode(data)) + self.connection.queue_send(self.encode(data)) diff --git a/tests/frontends/mpd/protocol/__init__.py b/tests/frontends/mpd/protocol/__init__.py index 8cd91d60..078153b5 100644 --- a/tests/frontends/mpd/protocol/__init__.py +++ b/tests/frontends/mpd/protocol/__init__.py @@ -14,7 +14,7 @@ class MockConnetion(mock.Mock): self.port = mock.sentinel.port self.response = [] - def send(self, data): + def queue_send(self, data): lines = (line for line in data.split('\n') if line) self.response.extend(lines) diff --git a/tests/utils/network/connection_test.py b/tests/utils/network/connection_test.py index 6e68f250..7e7ff05a 100644 --- a/tests/utils/network/connection_test.py +++ b/tests/utils/network/connection_test.py @@ -318,7 +318,7 @@ class ConnectionTest(unittest.TestCase): self.mock.send_lock = Mock() self.mock.send_buffer = '' - network.Connection.send(self.mock, 'data') + network.Connection.queue_send(self.mock, 'data') self.mock.send_lock.acquire.assert_called_once_with(True) self.mock.send_lock.release.assert_called_once_with() @@ -326,20 +326,20 @@ class ConnectionTest(unittest.TestCase): self.mock.send_lock = Mock() self.mock.send_buffer = '' - network.Connection.send(self.mock, 'abc') + network.Connection.queue_send(self.mock, 'abc') self.assertEqual('abc', self.mock.send_buffer) - network.Connection.send(self.mock, 'def') + network.Connection.queue_send(self.mock, 'def') self.assertEqual('abcdef', self.mock.send_buffer) - network.Connection.send(self.mock, '') + network.Connection.queue_send(self.mock, '') self.assertEqual('abcdef', self.mock.send_buffer) def test_send_calls_enable_send(self): self.mock.send_lock = Mock() self.mock.send_buffer = '' - network.Connection.send(self.mock, 'data') + network.Connection.queue_send(self.mock, 'data') self.mock.enable_send.assert_called_once_with() def test_recv_callback_respects_io_err(self): diff --git a/tests/utils/network/lineprotocol_test.py b/tests/utils/network/lineprotocol_test.py index 3d16f81c..4e7df132 100644 --- a/tests/utils/network/lineprotocol_test.py +++ b/tests/utils/network/lineprotocol_test.py @@ -196,7 +196,7 @@ class LineProtocolTest(unittest.TestCase): network.LineProtocol.send_lines(self.mock, []) self.assertEqual(0, self.mock.encode.call_count) - self.assertEqual(0, self.mock.connection.send.call_count) + self.assertEqual(0, self.mock.connection.queue_send.call_count) def test_send_lines_calls_join_lines(self): self.mock.connection = Mock(spec=network.Connection) @@ -218,7 +218,7 @@ class LineProtocolTest(unittest.TestCase): self.mock.encode.return_value = sentinel.data network.LineProtocol.send_lines(self.mock, sentinel.lines) - self.mock.connection.send.assert_called_once_with(sentinel.data) + self.mock.connection.queue_send.assert_called_once_with(sentinel.data) def test_join_lines_returns_empty_string_for_no_lines(self): self.assertEqual(u'', network.LineProtocol.join_lines(self.mock, []))