body = {"volume": vol}
req = fakes.HTTPRequest.blank('/v2/volumes')
res_dict = self.controller.create(req, body)
- expected = {
- 'volume': {
- 'name': 'Volume Test Name',
- 'id': '1',
- 'links': [
- {
- 'href': 'http://localhost/v1/fake/volumes/1',
- 'rel': 'self'
- },
- {
- 'href': 'http://localhost/fake/volumes/1',
- 'rel': 'bookmark'
- }
- ],
- }
- }
- self.assertEqual(res_dict, expected)
+ ex = {'volume': {'attachments':
+ [{'device': '/',
+ 'host_name': None,
+ 'id': '1',
+ 'server_id': 'fakeuuid',
+ 'volume_id': '1'}],
+ 'availability_zone': 'zone1:host1',
+ 'bootable': 'false',
+ 'created_at': datetime.datetime(1, 1, 1, 1, 1, 1),
+ 'description': 'Volume Test Desc',
+ 'id': '1',
+ 'links':
+ [{'href': 'http://localhost/v1/fake/volumes/1',
+ 'rel': 'self'},
+ {'href': 'http://localhost/fake/volumes/1',
+ 'rel': 'bookmark'}],
+ 'metadata': {'attached_mode': 'rw',
+ 'readonly': 'False'},
+ 'name': 'Volume Test Name',
+ 'size': 100,
+ 'snapshot_id': None,
+ 'source_volid': None,
+ 'status': 'fakestatus',
+ 'user_id': 'fakeuser',
+ 'volume_type': 'vol_type_name'}}
+ self.assertEqual(res_dict, ex)
def test_volume_create_with_type(self):
vol_type = db.volume_type_create(
"description": "Volume Test Desc",
"availability_zone": "nova",
"imageRef": 'c905cedb-7281-47e4-8a62-f26bc5fc4c77'}
- expected = {
- 'volume': {
- 'name': 'Volume Test Name',
- 'id': '1',
- 'links': [
- {
- 'href': 'http://localhost/v1/fake/volumes/1',
- 'rel': 'self'
- },
- {
- 'href': 'http://localhost/fake/volumes/1',
- 'rel': 'bookmark'
- }
- ],
- }
- }
+ ex = {'volume': {'attachments': [{'device': '/',
+ 'host_name': None,
+ 'id': '1',
+ 'server_id': 'fakeuuid',
+ 'volume_id': '1'}],
+ 'availability_zone': 'nova',
+ 'bootable': 'false',
+ 'created_at': datetime.datetime(1, 1, 1, 1, 1, 1),
+ 'description': 'Volume Test Desc',
+ 'id': '1',
+ 'links':
+ [{'href': 'http://localhost/v1/fake/volumes/1',
+ 'rel': 'self'},
+ {'href': 'http://localhost/fake/volumes/1',
+ 'rel': 'bookmark'}],
+ 'metadata': {'attached_mode': 'rw',
+ 'readonly': 'False'},
+ 'name': 'Volume Test Name',
+ 'size': '1',
+ 'snapshot_id': None,
+ 'source_volid': None,
+ 'status': 'fakestatus',
+ 'user_id': 'fakeuser',
+ 'volume_type': 'vol_type_name'}}
body = {"volume": vol}
req = fakes.HTTPRequest.blank('/v2/volumes')
res_dict = self.controller.create(req, body)
- self.assertEqual(res_dict, expected)
+ self.assertEqual(res_dict, ex)
def test_volume_create_with_image_id_is_integer(self):
self.stubs.Set(volume_api.API, "create", stubs.stub_volume_create)