'Tests GET /os-hypervisors?with_servers=True'

def test_list_with_servers(self):

    instances = [objects.InstanceList(objects=[objects.Instance(id=1, uuid=uuids.hyper1_instance1)]), objects.InstanceList(objects=[objects.Instance(id=2, uuid=uuids.hyper2_instance1)])]
    with mock.patch.object(self.controller.host_api, 'instance_get_all_by_host', side_effect=instances) as mock_inst_get_all:
        req = self._get_request(use_admin_context=True, url='/os-hypervisors?with_servers=True')
        result = self.controller.index(req)
    index_with_servers = copy.deepcopy(self.INDEX_HYPER_DICTS)
    index_with_servers[0]['servers'] = [{'name': 'instance-00000001', 'uuid': uuids.hyper1_instance1}]
    index_with_servers[1]['servers'] = [{'name': 'instance-00000002', 'uuid': uuids.hyper2_instance1}]
    self.assertEqual(dict(hypervisors=index_with_servers), result)
    self.assertEqual(2, mock_inst_get_all.call_count)
    mock_inst_get_all.assert_has_calls((mock.call(req.environ['nova.context'], TEST_HYPERS_OBJ[0].host), mock.call(req.environ['nova.context'], TEST_HYPERS_OBJ[1].host)))
