'We want to make sure that if two instances are on the same host,
then they return the same hostId. If two instances are on different
hosts, they should return different hostIds. In this test,
there are 5 instances - 2 on one host and 3 on another.'

def test_get_all_server_details_with_host(self):

    def return_servers_with_host(*args, **kwargs):
        return objects.InstanceList(objects=[fakes.stub_instance_obj(None, id=(i + 1), user_id='fake', project_id='fake', host=(i % 2), uuid=fakes.get_fake_uuid(i)) for i in range(5)])
    self.stubs.Set(compute_api.API, 'get_all', return_servers_with_host)
    req = self.req('/fake/servers/detail')
    res_dict = self.controller.detail(req)
    server_list = res_dict['servers']
    host_ids = [server_list[0]['hostId'], server_list[1]['hostId']]
    self.assertTrue((host_ids[0] and host_ids[1]))
    self.assertNotEqual(host_ids[0], host_ids[1])
    for (i, s) in enumerate(server_list):
        self.assertEqual(s['id'], fakes.get_fake_uuid(i))
        self.assertEqual(s['hostId'], host_ids[(i % 2)])
        self.assertEqual(s['name'], ('server%d' % (i + 1)))
