def test_detail(self):
     req = wsgi.Request({'nova.context':
                 fakes.FakeRequestContext('fake_user', 'fake',
                                          is_admin=True)})
     instance1 = {'uuid': 'fake1',
                  'access_ip_v4': '1.1.1.1',
                  'access_ip_v6': 'fe80::'}
     instance2 = {'uuid': 'fake2',
                  'access_ip_v4': '1.1.1.2',
                  'access_ip_v6': 'fe81::'}
     req.cache_db_instance(instance1)
     req.cache_db_instance(instance2)
     resp_obj = wsgi.ResponseObject(
         {"servers": [{'id': 'fake1'}, {'id': 'fake2'}]})
     self.controller.detail(req, resp_obj)
     self.assertEqual(
         resp_obj.obj['servers'][0][access_ips.AccessIPs.v4_key],
         '1.1.1.1')
     self.assertEqual(
         resp_obj.obj['servers'][0][access_ips.AccessIPs.v6_key],
         'fe80::')
     self.assertEqual(
         resp_obj.obj['servers'][1][access_ips.AccessIPs.v4_key],
         '1.1.1.2')
     self.assertEqual(
         resp_obj.obj['servers'][1][access_ips.AccessIPs.v6_key],
         'fe81::')
Exemple #2
0
 def test_create_with_reservation_id(self):
     req = wsgi.Request({
         'nova.context':
         fakes.FakeRequestContext('fake_user', 'fake', is_admin=True)
     })
     expected_res = {'servers_reservation': {'reservation_id': 'test'}}
     body = copy.deepcopy(expected_res)
     resp_obj = wsgi.ResponseObject(body)
     self.controller.create(req, resp_obj, body)
     self.assertEqual(expected_res, resp_obj.obj)
 def _test_without_access_ips(self, func, kwargs={'id': 'fake'}):
     req = wsgi.Request({
         'nova.context':
         fakes.FakeRequestContext('fake_user', 'fake', is_admin=True)
     })
     instance = {'uuid': 'fake', 'access_ip_v4': None, 'access_ip_v6': None}
     req.cache_db_instance(instance)
     resp_obj = wsgi.ResponseObject({"server": {'id': 'fake'}})
     func(req, resp_obj, **kwargs)
     self.assertEqual(resp_obj.obj['server'][access_ips.AccessIPs.v4_key],
                      '')
     self.assertEqual(resp_obj.obj['server'][access_ips.AccessIPs.v6_key],
                      '')