class TestHaproxyDriverRemoteSocketOperation(unittest.TestCase):
    def setUp(self):
        self.remote_socket = RemoteSocketOperation(device_fake, backend, rserver)
        self.remote_socket.ssh = Mock()
        file_channel = MagicMock(spec=file)
        self.remote_socket.ssh.exec_command.return_value = [file_channel, file_channel, file_channel]

    def test_get_statistics(self):
        self.assertTrue(self.remote_socket.get_statistics())
    def get_statistics(self, serverfarm, rserver):
        haproxy_rserver = HaproxyRserver()
        haproxy_rserver.name = rserver['name']
        haproxy_serverfarm = HaproxyBackend()
        haproxy_serverfarm.name = serverfarm['name']
        remote_socket = RemoteSocketOperation(self.device_ref,
                                        haproxy_serverfarm, haproxy_rserver,
                                        self.interface, self.haproxy_socket)
        out = remote_socket.get_statistics()
        statistics = {}
        if out:
            status_line = out.split(",")
            statistics['weight'] = status_line[18]
            statistics['state'] = status_line[17]
            statistics['connCurrent'] = [4]
            statistics['connTotal'] = [7]
            statistics['connFail'] = [13]
            statistics['connMax'] = [5]
            statistics['connRateLimit'] = [34]
            statistics['bandwRateLimit'] = [35]
# NOTE: broken because use indeterminate state variable
#        logger.debug('[HAPROXY] statistics rserver state is \'%s\'',
#                statistics.state)
        return statistics