except exception.NotFound:
raise exc.HTTPNotFound()
- # TODO(bcwaldon): remove str cast once we use uuids
- vol_type['id'] = str(vol_type['id'])
return self._view_builder.show(req, vol_type)
if vol['volume_type_id'] and vol.get('volume_type'):
d['volume_type'] = vol['volume_type']['name']
else:
- # TODO(bcwaldon): remove str cast once we use uuids
- d['volume_type'] = str(vol['volume_type_id'])
+ d['volume_type'] = vol['volume_type_id']
d['snapshot_id'] = vol['snapshot_id']
d['source_volid'] = vol['source_volid']
msg = _("Volume type not found")
raise exc.HTTPNotFound(explanation=msg)
- # TODO(bcwaldon): remove str cast once we use uuids
- vol_type['id'] = str(vol_type['id'])
return self._view_builder.show(req, vol_type)
# License for the specific language governing permissions and limitations
# under the License.
+import uuid
+
from lxml import etree
import webob
def return_volume_types_get_volume_type(context, id):
if id == "777":
raise exception.VolumeTypeNotFound(volume_type_id=id)
- return stub_volume_type(int(id))
+ return stub_volume_type(id)
def return_volume_types_get_by_name(context, name):
self.stubs.Set(volume_types, 'get_volume_type',
return_volume_types_get_volume_type)
- req = fakes.HTTPRequest.blank('/v1/fake/types/1')
- res_dict = self.controller.show(req, 1)
+ type_id = str(uuid.uuid4())
+ req = fakes.HTTPRequest.blank('/v1/fake/types/' + type_id)
+ res_dict = self.controller.show(req, type_id)
self.assertEqual(1, len(res_dict))
- self.assertEqual('1', res_dict['volume_type']['id'])
- self.assertEqual('vol_type_1', res_dict['volume_type']['name'])
+ self.assertEqual(type_id, res_dict['volume_type']['id'])
+ vol_type_name = 'vol_type_' + type_id
+ self.assertEqual(vol_type_name, res_dict['volume_type']['name'])
def test_volume_types_show_not_found(self):
self.stubs.Set(volume_types, 'get_volume_type',
'device': '/'
}],
'bootable': 'false',
- 'volume_type': 'None',
+ 'volume_type': None,
'snapshot_id': None,
'source_volid': None,
'metadata': {'key': 'value',
'id': '1',
'volume_id': '1'}],
'bootable': 'false',
- 'volume_type': 'None',
+ 'volume_type': None,
'snapshot_id': None,
'source_volid': None,
'metadata': {'key': 'value',
'id': '1',
'volume_id': '1'}],
'bootable': 'false',
- 'volume_type': 'None',
+ 'volume_type': None,
'snapshot_id': None,
'source_volid': None,
'metadata': {'key': 'value',
'id': '1',
'volume_id': '1'}],
'bootable': 'false',
- 'volume_type': 'None',
+ 'volume_type': None,
'snapshot_id': None,
'source_volid': None,
'metadata': {'key': 'value',
# License for the specific language governing permissions and limitations
# under the License.
+import uuid
+
from lxml import etree
import webob
def return_volume_types_get_volume_type(context, id):
if id == "777":
raise exception.VolumeTypeNotFound(volume_type_id=id)
- return stub_volume_type(int(id))
+ return stub_volume_type(id)
def return_volume_types_get_by_name(context, name):
self.stubs.Set(volume_types, 'get_volume_type',
return_volume_types_get_volume_type)
- req = fakes.HTTPRequest.blank('/v2/fake/types/1')
- res_dict = self.controller.show(req, 1)
+ type_id = str(uuid.uuid4())
+ req = fakes.HTTPRequest.blank('/v2/fake/types/' + type_id)
+ res_dict = self.controller.show(req, type_id)
self.assertEqual(1, len(res_dict))
- self.assertEqual('1', res_dict['volume_type']['id'])
- self.assertEqual('vol_type_1', res_dict['volume_type']['name'])
+ self.assertEqual(type_id, res_dict['volume_type']['id'])
+ type_name = 'vol_type_' + type_id
+ self.assertEqual(type_name, res_dict['volume_type']['name'])
def test_volume_types_show_not_found(self):
self.stubs.Set(volume_types, 'get_volume_type',