def calvincontrol(): control = CalvinControl() control.send_response = Mock() control.send_response = Mock() control.node = Mock() control.node.quitting = False return control
def calvincontrol(): control = CalvinControl() control.send_response = Mock() control.send_response = Mock() control.node = Mock() control.node.quitting = False return control
def test_send_response(): control = CalvinControl() control.tunnel_client = Mock() handle = Mock() connection = Mock() data = {'value': 1} status = 200 control.connections[handle] = connection control.send_response(handle, None, data, status) assert control.tunnel_client.send.called control.connections[handle] = connection connection.connection_lost = True control.send_response(handle, connection, data, status) assert not connection.send.called control.connections[handle] = connection connection.connection_lost = False control.send_response(handle, connection, data, status) assert connection.send.called connection.send.assert_called_with(data) assert handle not in control.connections
def test_send_response(): control = CalvinControl() control.tunnel_client = Mock() handle = Mock() connection = Mock() data = {'value': 1} status = 200 control.connections[handle] = connection control.send_response(handle, None, data, status) assert control.tunnel_client.send.called control.connections[handle] = connection connection.connection_lost = True control.send_response(handle, connection, data, status) assert not connection.send.called control.connections[handle] = connection connection.connection_lost = False control.send_response(handle, connection, data, status) assert connection.send.called connection.send.assert_called_with(data) assert handle not in control.connections
def calvincontrol(): control = CalvinControl() control.send_response = Mock() control.send_response = Mock() return control
def calvincontrol(): control = CalvinControl() control.send_response = Mock() control.send_response = Mock() return control