def test_migrate_live_destination_hypervisor_too_old(self): ctxt = context.get_admin_context() ctxt.user_id = 'fake' ctxt.project_id = 'fake' ctxt.is_admin = True app = fakes.wsgi_app_v3(fake_auth_context=ctxt, init_only=('servers', 'os-admin-actions')) req = webob.Request.blank('/v3/servers/%s/action' % self.UUID) req.method = 'POST' req.body = jsonutils.dumps({ 'os-migrateLive': { 'host': 'hostname', 'block_migration': False, 'disk_over_commit': False, } }) req.content_type = 'application/json' def fake_update(inst, context, instance, task_state, expected_task_state): return None def fake_migrate_server(self, context, instance, scheduler_hint, live, rebuild, flavor, block_migration, disk_over_commit): raise exception.DestinationHypervisorTooOld() self.stubs.Set(compute_api.API, 'update', fake_update) self.stubs.Set(conductor_api.ComputeTaskAPI, 'migrate_server', fake_migrate_server) res = req.get_response(app) self.assertEqual(res.status_int, 400) self.assertIn(unicode(exception.DestinationHypervisorTooOld()), res.body)
def setUp(self): super(ConsoleOutputExtensionTest, self).setUp() self.stubs.Set(compute_api.API, 'get_console_output', fake_get_console_output) self.stubs.Set(compute_api.API, 'get', fake_get) self.app = fakes.wsgi_app_v3(init_only=('servers', 'os-console-output'))
def _test_verify_show(self, start, stop): tenant_id = 0 req = webob.Request.blank( '/v3/os-simple-tenant-usage/' 'faketenant_%s?start=%s&end=%s' % (tenant_id, start.isoformat(), stop.isoformat())) req.method = "GET" req.headers["content-type"] = "application/json" res = req.get_response( fakes.wsgi_app_v3(fake_auth_context=self.user_context, init_only=('os-simple-tenant-usage', 'servers'))) self.assertEqual(res.status_int, 200) res_dict = jsonutils.loads(res.body) usage = res_dict['tenant_usage'] servers = usage['server_usages'] self.assertEqual(len(usage['server_usages']), SERVERS) uuids = [ '00000000-0000-0000-0000-00000000000000%02d' % (x + (tenant_id * SERVERS)) for x in xrange(SERVERS) ] for j in xrange(SERVERS): delta = STOP - START uptime = delta.days * 24 * 3600 + delta.seconds self.assertEqual(int(servers[j]['uptime']), uptime) self.assertEqual(int(servers[j]['hours']), HOURS) self.assertTrue(servers[j]['instance_id'] in uuids)
def _make_request(self, url, method='GET'): req = webob.Request.blank(url) req.headers['Accept'] = self.content_type req.method = method res = req.get_response( fakes.wsgi_app_v3(init_only=('servers', 'os-server-password'))) return res
def _test_verify_show(self, start, stop): tenant_id = 0 req = webob.Request.blank( '/v3/os-simple-tenant-usage/' 'faketenant_%s?start=%s&end=%s' % (tenant_id, start.isoformat(), stop.isoformat())) req.method = "GET" req.headers["content-type"] = "application/json" res = req.get_response(fakes.wsgi_app_v3( fake_auth_context=self.user_context, init_only=('os-simple-tenant-usage', 'servers'))) self.assertEqual(res.status_int, 200) res_dict = jsonutils.loads(res.body) usage = res_dict['tenant_usage'] servers = usage['server_usages'] self.assertEqual(len(usage['server_usages']), SERVERS) uuids = ['00000000-0000-0000-0000-00000000000000%02d' % (x + (tenant_id * SERVERS)) for x in xrange(SERVERS)] for j in xrange(SERVERS): delta = STOP - START uptime = delta.days * 24 * 3600 + delta.seconds self.assertEqual(int(servers[j]['uptime']), uptime) self.assertEqual(int(servers[j]['hours']), HOURS) self.assertIn(servers[j]['instance_id'], uuids)
def test_get_version_3_detail_content_type(self): req = webob.Request.blank("/") req.accept = "application/json;version=3" res = req.get_response(fakes.wsgi_app_v3()) self.assertEqual(res.status_int, 200) self.assertEqual(res.content_type, "application/json") version = jsonutils.loads(res.body) expected = { "version": { "id": "v3.0", "status": "EXPERIMENTAL", "updated": "2013-07-23T11:33:21Z", "links": [{"rel": "self", "href": "http://localhost/v3/"}], "links": [ {"rel": "self", "href": "http://localhost/v3/"}, {"rel": "describedby", "type": "application/pdf", "href": EXP_LINKS["v3.0"]["pdf"]}, {"rel": "describedby", "type": "application/vnd.sun.wadl+xml", "href": EXP_LINKS["v3.0"]["wadl"]}, ], "media-types": [ {"base": "application/xml", "type": "application/" "vnd.openstack.compute+xml;version=3"}, {"base": "application/json", "type": "application/" "vnd.openstack.compute+json;version=3"}, ], } } self.assertEqual(expected, version)
def _make_request(self, url): req = webob.Request.blank(url) req.headers['Accept'] = self.content_type app = fakes.wsgi_app_v3(init_only=('servers', 'flavors', 'os-flavor-rxtx')) res = req.get_response(app) return res
def test_get_version_list_302(self): req = webob.Request.blank('/v3') req.accept = "application/json" res = req.get_response(fakes.wsgi_app_v3()) self.assertEqual(res.status_int, 302) redirect_req = webob.Request.blank('/v3/') self.assertEqual(res.location, redirect_req.url)
def setUp(self): super(ServerActionsControllerTest, self).setUp() CONF.set_override('host', 'localhost', group='glance') self.stubs.Set(db, 'instance_get_by_uuid', fakes.fake_instance_get(vm_state=vm_states.ACTIVE, host='fake_host')) self.stubs.Set(db, 'instance_update_and_get_original', instance_update_and_get_original) fakes.stub_out_nw_api(self.stubs) fakes.stub_out_compute_api_snapshot(self.stubs) fake.stub_out_image_service(self.stubs) self.flags(allow_instance_snapshots=True, enable_instance_password=True) self.uuid = FAKE_UUID self.url = '/servers/%s/action' % self.uuid self._image_href = '155d900f-4e14-4e4c-a73d-069cbf4541e6' ext_info = plugins.LoadedExtensionInfo() self.controller = servers.ServersController(extension_info=ext_info) self.compute_api = self.controller.compute_api self.context = context.RequestContext('fake', 'fake') self.app = fakes.wsgi_app_v3(init_only=('servers',), fake_auth_context=self.context)
def setUp(self): super(FlavorManageTest, self).setUp() self.stubs.Set(flavors, "get_flavor_by_flavor_id", fake_get_flavor_by_flavor_id) self.stubs.Set(flavors, "destroy", fake_destroy) self.stubs.Set(db, "flavor_create", fake_create) self.controller = flavor_manage.FlavorManageController() self.app = fakes.wsgi_app_v3(init_only=('servers', 'flavors', 'flavor-manage', 'os-flavor-rxtx', 'flavor-access')) self.expected_flavor = { "flavor": { "name": "test", "ram": 512, "vcpus": 2, "disk": 1, "ephemeral": 1, "id": unicode('1234'), "swap": 512, "rxtx_factor": 1, "flavor-access:is_public": True, } }
def setUp(self): super(RescueTest, self).setUp() self.stubs.Set(compute.api.API, "get", fake_compute_get) self.stubs.Set(compute.api.API, "rescue", rescue) self.stubs.Set(compute.api.API, "unrescue", unrescue) self.app = fakes.wsgi_app_v3(init_only=('servers', 'os-rescue'))
def test_get_version_list_302(self): req = webob.Request.blank("/v3") req.accept = "application/json" res = req.get_response(fakes.wsgi_app_v3()) self.assertEqual(res.status_int, 302) redirect_req = webob.Request.blank("/v3/") self.assertEqual(res.location, redirect_req.url)
def test_migrate_too_many_instances(self): app = fakes.wsgi_app_v3(init_only=('servers', 'os-admin-actions')) self.stubs.Set(compute_api.API, 'resize', fake_compute_api_too_many_instaces) res = self._make_request('/v3/servers/%s/action' % self.UUID, {'migrate': None}) self.assertEqual(res.status_int, 413)
def test_admin_api_actions_with_non_existed_instance(self): app = fakes.wsgi_app_v3(init_only=('servers', 'os-admin-actions')) self.stubs.Set(compute_api.API, 'get', fake_compute_api_get_non_found) for _action in self._actions_that_check_non_existed_instance: res = self._make_request('/v3/servers/%s/action' % self.UUID, {_action: None}) self.assertEqual(res.status_int, 404)
def setUp(self): super(ServerActionsControllerTest, self).setUp() CONF.set_override('glance_host', 'localhost') self.stubs.Set(db, 'instance_get_by_uuid', fakes.fake_instance_get(vm_state=vm_states.ACTIVE, host='fake_host')) self.stubs.Set(db, 'instance_update_and_get_original', instance_update_and_get_original) fakes.stub_out_glance(self.stubs) fakes.stub_out_nw_api(self.stubs) fakes.stub_out_compute_api_snapshot(self.stubs) fake.stub_out_image_service(self.stubs) service_class = 'nova.image.glance.GlanceImageService' self.service = importutils.import_object(service_class) self.sent_to_glance = {} fakes.stub_out_glanceclient_create(self.stubs, self.sent_to_glance) self.flags(allow_instance_snapshots=True, enable_instance_password=True) self.uuid = FAKE_UUID self.url = '/servers/%s/action' % self.uuid self._image_href = '155d900f-4e14-4e4c-a73d-069cbf4541e6' ext_info = plugins.LoadedExtensionInfo() self.controller = servers.ServersController(extension_info=ext_info) self.compute_api = self.controller.compute_api self.context = context.RequestContext('fake', 'fake') self.app = fakes.wsgi_app_v3(init_only=('servers',), fake_auth_context=self.context)
def _test_verify_index(self, start, stop): req = webob.Request.blank( '/v3/os-simple-tenant-usage?start=%s&end=%s' % (start.isoformat(), stop.isoformat())) req.method = "GET" req.headers["content-type"] = "application/json" res = req.get_response(fakes.wsgi_app_v3( fake_auth_context=self.admin_context, init_only=('os-simple-tenant-usage', 'servers'))) self.assertEqual(res.status_int, 200) res_dict = jsonutils.loads(res.body) usages = res_dict['tenant_usages'] for i in xrange(TENANTS): self.assertEqual(int(usages[i]['total_hours']), SERVERS * HOURS) self.assertEqual(int(usages[i]['total_local_gb_usage']), SERVERS * (ROOT_GB + EPHEMERAL_GB) * HOURS) self.assertEqual(int(usages[i]['total_memory_mb_usage']), SERVERS * MEMORY_MB * HOURS) self.assertEqual(int(usages[i]['total_vcpus_usage']), SERVERS * VCPUS * HOURS) self.assertFalse(usages[i].get('server_usages'))
def _make_request(self, url): req = webob.Request.blank(url) req.headers['Accept'] = self.content_type res = req.get_response( fakes.wsgi_app_v3(init_only=('servers', 'os-extended-server-attributes'))) return res
def setUp(self): super(AdminPasswordTest, self).setUp() self.stubs.Set(compute_api.API, 'set_admin_password', fake_set_admin_password) self.stubs.Set(compute_api.API, 'get', fake_get) self.app = fakes.wsgi_app_v3(init_only=('servers', admin_password.ALIAS))
def setUp(self): super(AdminActionsTest, self).setUp() self.stubs.Set(compute_api.API, 'get', fake_compute_api_get) self.UUID = uuidutils.generate_uuid() self.app = fakes.wsgi_app_v3(init_only=('servers', 'os-admin-actions')) for _method in self._methods: self.stubs.Set(compute_api.API, _method, fake_compute_api)
def test_migrate_resize_to_same_flavor(self): app = fakes.wsgi_app_v3(init_only=('servers', 'os-admin-actions')) self.stubs.Set(compute_api.API, 'resize', fake_compute_api_can_not_resize_to_same_flavor) res = self._make_request('/v3/servers/%s/action' % self.UUID, {'migrate': None}) self.assertEqual(res.status_int, 400)
def test_get_version_3_detail_atom(self): req = webob.Request.blank("/v3/") req.accept = "application/atom+xml" res = req.get_response(fakes.wsgi_app_v3()) self.assertEqual(res.status_int, 200) self.assertEqual("application/atom+xml", res.content_type) xmlutil.validate_schema(etree.XML(res.body), "atom") f = feedparser.parse(res.body) self.assertEqual(f.feed.title, "About This Version") self.assertEqual(f.feed.updated, "2013-07-23T11:33:21Z") self.assertEqual(f.feed.id, "http://localhost/v3/") self.assertEqual(f.feed.author, "Rackspace") self.assertEqual(f.feed.author_detail.href, "http://www.rackspace.com/") self.assertEqual(f.feed.links[0]["href"], "http://localhost/v3/") self.assertEqual(f.feed.links[0]["rel"], "self") self.assertEqual(len(f.entries), 1) entry = f.entries[0] self.assertEqual(entry.id, "http://localhost/v3/") self.assertEqual(entry.title, "Version v3.0") self.assertEqual(entry.updated, "2013-07-23T11:33:21Z") self.assertEqual(len(entry.content), 1) self.assertEqual(entry.content[0].value, "Version v3.0 EXPERIMENTAL (2013-07-23T11:33:21Z)") self.assertEqual(len(entry.links), 3) self.assertEqual(entry.links[0]["href"], "http://localhost/v3/") self.assertEqual(entry.links[0]["rel"], "self") self.assertEqual( entry.links[1], {"href": EXP_LINKS["v3.0"]["pdf"], "type": "application/pdf", "rel": "describedby"} ) self.assertEqual( entry.links[2], {"href": EXP_LINKS["v3.0"]["wadl"], "type": "application/vnd.sun.wadl+xml", "rel": "describedby"}, )
def test_evacuate_instance_with_target(self): ctxt = context.get_admin_context() ctxt.user_id = 'fake' ctxt.project_id = 'fake' ctxt.is_admin = True app = fakes.wsgi_app_v3(fake_auth_context=ctxt) uuid1 = self.UUID req = webob.Request.blank('/v3/servers/%s/action' % uuid1) req.method = 'POST' req.body = jsonutils.dumps({ 'evacuate': { 'host': 'my_host', 'onSharedStorage': 'false', 'adminPass': '******' } }) req.content_type = 'application/json' def fake_update(inst, context, instance, task_state, expected_task_state): return None self.stubs.Set(compute_api.API, 'update', fake_update) resp = req.get_response(app) self.assertEqual(resp.status_int, 200) resp_json = jsonutils.loads(resp.body) self.assertEqual("MyNewPass", resp_json['adminPass'])
def setUp(self): super(FlavorManageTest, self).setUp() self.stubs.Set(flavors, "get_flavor_by_flavor_id", fake_get_flavor_by_flavor_id) self.stubs.Set(flavors, "destroy", fake_destroy) self.stubs.Set(flavors, "create", fake_create) self.controller = flavor_manage.FlavorManageController() self.app = fakes.wsgi_app_v3(init_only=('servers', 'flavors', 'flavor-manage', 'os-flavor-rxtx', 'os-flavor-access')) self.expected_flavor = { "flavor": { "name": "test", "ram": 512, "vcpus": 2, "disk": 1, "ephemeral": 1, "id": 1234, "swap": 512, "rxtx_factor": 1, "os-flavor-access:is_public": True, } }
def test_migrate_live_enabled(self): ctxt = context.get_admin_context() ctxt.user_id = 'fake' ctxt.project_id = 'fake' ctxt.is_admin = True app = fakes.wsgi_app_v3(fake_auth_context=ctxt, init_only=('servers', 'os-admin-actions')) req = webob.Request.blank('/v3/servers/%s/action' % self.UUID) req.method = 'POST' req.body = jsonutils.dumps({ 'os-migrateLive': { 'host': 'hostname', 'block_migration': False, 'disk_over_commit': False, } }) req.content_type = 'application/json' def fake_update(inst, context, instance, task_state, expected_task_state): return None def fake_migrate_server(self, context, instance, scheduler_hint, live, rebuild, flavor, block_migration, disk_over_commit): return None self.stubs.Set(compute_api.API, 'update', fake_update) self.stubs.Set(conductor_api.ComputeTaskAPI, 'migrate_server', fake_migrate_server) res = req.get_response(app) self.assertEqual(res.status_int, 202)
def test_reset_state_with_non_existed_instance(self): app = fakes.wsgi_app_v3(init_only=('servers', 'os-admin-actions')) self.stubs.Set(compute_api.API, 'get', fake_compute_api_get_non_found) res = self._make_request('/v3/servers/%s/action' % self.UUID, {'reset_state': { 'state': 'active' }}) self.assertEqual(res.status_int, 404)
def test_stop_coverage_action_nostart(self): body = {"stop": {}} req = webob.Request.blank("/v3/os-coverage/action") req.method = "POST" req.body = jsonutils.dumps(body) req.headers["content-type"] = "application/json" res = req.get_response(fakes.wsgi_app_v3(fake_auth_context=self.admin_context)) self.assertEqual(res.status_int, 409)
def setUp(self): super(SecurityGroupsOutputTest, self).setUp() fakes.stub_out_nw_api(self.stubs) self.stubs.Set(compute.api.API, 'get', fake_compute_get) self.stubs.Set(compute.api.API, 'get_all', fake_compute_get_all) self.stubs.Set(compute.api.API, 'create', fake_compute_create) self.app = fakes.wsgi_app_v3(init_only=('servers', 'os-security-groups'))
def test_admin_api_actions_with_locked_instance(self): app = fakes.wsgi_app_v3(init_only=('servers', 'os-admin-actions')) for _action, _method in self._actions_that_check_is_locked: self.stubs.Set(compute_api.API, _method, fake_compute_api_raises_instance_is_locked) res = self._make_request('/v3/servers/%s/action' % self.UUID, {_action: None}) self.assertEqual(res.status_int, 409)
def test_authorize_user(self): req = webob.Request.blank("/v3") req.headers["X-Auth-User"] = "******" req.headers["X-Auth-Key"] = "user1_key" req.headers["X-Auth-Project-Id"] = "user1_project" result = req.get_response(fakes.wsgi_app_v3(use_no_auth=True)) self.assertEqual(result.status, "204 No Content") self.assertEqual(result.headers["X-Server-Management-Url"], "http://localhost/v3")
def test_show(self): self.stubs.Set(db, "instance_get", fakes.fake_instance_get()) req = webob.Request.blank("/v3/servers/1") req.headers["Content-Type"] = "application/json" response = req.get_response(fakes.wsgi_app_v3(init_only=("servers", "os-config-drive"))) self.assertEquals(response.status_int, 200) res_dict = jsonutils.loads(response.body) self.assertTrue("config_drive" in res_dict["server"])
def test_detail_servers(self): self.stubs.Set(db, "instance_get_all_by_filters", fakes.fake_instance_get_all_by_filters()) req = fakes.HTTPRequestV3.blank("/v3/servers/detail") res = req.get_response(fakes.wsgi_app_v3(init_only=("servers", "os-config-drive"))) server_dicts = jsonutils.loads(res.body)["servers"] self.assertNotEqual(len(server_dicts), 0) for server_dict in server_dicts: self.assertTrue("config_drive" in server_dict)
def setUp(self): super(ConsoleAuthTokensExtensionTest, self).setUp() self.stubs.Set(consoleauth_rpcapi.ConsoleAuthAPI, 'check_token', _fake_check_token) ctxt = self._get_admin_context() self.app = fakes.wsgi_app_v3(init_only=('os-console-auth-tokens'), fake_auth_context=ctxt)
def setUp(self): super(SecurityGroupsOutputTest, self).setUp() CONF.set_override("security_group_api", "nova") fakes.stub_out_nw_api(self.stubs) self.stubs.Set(compute.api.API, "get", fake_compute_get) self.stubs.Set(compute.api.API, "get_all", fake_compute_get_all) self.stubs.Set(compute.api.API, "create", fake_compute_create) self.app = fakes.wsgi_app_v3(init_only=("servers", "os-security-groups"))
def test_admin_api_actions(self): app = fakes.wsgi_app_v3(init_only=('servers', 'os-admin-actions')) for _action in self._actions: req = webob.Request.blank('/v3/servers/%s/action' % self.UUID) req.method = 'POST' req.body = jsonutils.dumps({_action: None}) req.content_type = 'application/json' res = req.get_response(app) self.assertEqual(res.status_int, 202)
def test_stop_coverage_action_nostart(self): body = {'stop': {}} req = webob.Request.blank('/v3/os-coverage/action') req.method = "POST" req.body = jsonutils.dumps(body) req.headers["content-type"] = "application/json" res = req.get_response( fakes.wsgi_app_v3(fake_auth_context=self.admin_context)) self.assertEqual(res.status_int, 404)
def test_get_version_3_detail_content_type(self): req = webob.Request.blank('/') req.accept = "application/json;version=3" res = req.get_response(fakes.wsgi_app_v3()) self.assertEqual(res.status_int, 200) self.assertEqual(res.content_type, "application/json") version = jsonutils.loads(res.body) expected = {"version": EXP_VERSIONS['v3.0']} self.assertEqual(expected, version)
def test_authorize_user(self): req = webob.Request.blank('/v3') req.headers['X-Auth-User'] = '******' req.headers['X-Auth-Key'] = 'user1_key' req.headers['X-Auth-Project-Id'] = 'user1_project' result = req.get_response(fakes.wsgi_app_v3(use_no_auth=True)) self.assertEqual(result.status, '204 No Content') self.assertEqual(result.headers['X-Server-Management-Url'], "http://localhost/v3")
def test_auth_token_no_empty_headers(self): req = webob.Request.blank('/v3') req.headers['X-Auth-User'] = '******' req.headers['X-Auth-Key'] = 'user1_key' req.headers['X-Auth-Project-Id'] = 'user1_project' result = req.get_response(fakes.wsgi_app_v3(use_no_auth=True)) self.assertEqual(result.status, '204 No Content') self.assertNotIn('X-CDN-Management-Url', result.headers) self.assertNotIn('X-Storage-Url', result.headers)
def test_auth_token_no_empty_headers(self): req = webob.Request.blank("/v3") req.headers["X-Auth-User"] = "******" req.headers["X-Auth-Key"] = "user1_key" req.headers["X-Auth-Project-Id"] = "user1_project" result = req.get_response(fakes.wsgi_app_v3(use_no_auth=True)) self.assertEqual(result.status, "204 No Content") self.assertFalse("X-CDN-Management-Url" in result.headers) self.assertFalse("X-Storage-Url" in result.headers)
def test_accept_version_v3(self): # Test Accept header specifying v3 returns v3 content. req = webob.Request.blank('/') req.accept = "application/json;version=3" res = req.get_response(fakes.wsgi_app_v3(init_only=('versions', ))) self.assertEqual(res.status_int, 200) self.assertEqual(res.content_type, "application/json") body = jsonutils.loads(res.body) self.assertEqual(body['version']['id'], 'v3.0')
def test_auth_token_no_empty_headers(self): req = webob.Request.blank('/v3') req.headers['X-Auth-User'] = '******' req.headers['X-Auth-Key'] = 'user1_key' req.headers['X-Auth-Project-Id'] = 'user1_project' result = req.get_response(fakes.wsgi_app_v3(use_no_auth=True)) self.assertEqual(result.status, '204 No Content') self.assertFalse('X-CDN-Management-Url' in result.headers) self.assertFalse('X-Storage-Url' in result.headers)
def setUp(self): super(ConsolesExtensionTest, self).setUp() self.stubs.Set(compute_api.API, 'get_vnc_console', fake_get_vnc_console) self.stubs.Set(compute_api.API, 'get_spice_console', fake_get_spice_console) self.stubs.Set(compute_api.API, 'get', fake_get) self.app = fakes.wsgi_app_v3(init_only=('servers', 'os-remote-consoles'))
def test_get_version_3_detail(self): req = webob.Request.blank('/v3/') req.accept = "application/json" res = req.get_response(fakes.wsgi_app_v3()) self.assertEqual(res.status_int, 200) self.assertEqual(res.content_type, "application/json") version = jsonutils.loads(res.body) expected = { "version": { "id": "v3.0", "status": "EXPERIMENTAL", "updated": "2013-07-23T11:33:21Z", "links": [ { "rel": "self", "href": "http://localhost/v3/", }, ], "links": [ { "rel": "self", "href": "http://localhost/v3/", }, { "rel": "describedby", "type": "application/pdf", "href": EXP_LINKS['v3.0']['pdf'], }, { "rel": "describedby", "type": "application/vnd.sun.wadl+xml", "href": EXP_LINKS['v3.0']['wadl'], }, ], "media-types": [ { "base": "application/xml", "type": "application/" "vnd.openstack.compute+xml;version=3", }, { "base": "application/json", "type": "application/" "vnd.openstack.compute+json;version=3", }, ], }, } self.assertEqual(expected, version)
def test_show(self): self.stubs.Set(db, 'instance_get', fakes.fake_instance_get()) self.stubs.Set(db, 'instance_get_by_uuid', fakes.fake_instance_get()) req = webob.Request.blank('/v3/servers/1') req.headers['Content-Type'] = 'application/json' response = req.get_response( fakes.wsgi_app_v3(init_only=('servers', 'os-config-drive'))) self.assertEqual(response.status_int, 200) res_dict = jsonutils.loads(response.body) self.assertIn(config_drive.ATTRIBUTE_NAME, res_dict['server'])