Rename send to send_queue in network.Connection
This commit is contained in:
parent
709fc59e43
commit
13d4510e12
@ -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))
|
||||
|
||||
@ -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)
|
||||
|
||||
|
||||
@ -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):
|
||||
|
||||
@ -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, []))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user