diff --git a/openstackclient/tests/volume/v2/test_volume.py b/openstackclient/tests/volume/v2/test_volume.py index fe22b2137b..76c7a27a39 100644 --- a/openstackclient/tests/volume/v2/test_volume.py +++ b/openstackclient/tests/volume/v2/test_volume.py @@ -16,6 +16,7 @@ import copy from mock import call +from openstackclient.common import utils from openstackclient.tests import fakes from openstackclient.tests.identity.v3 import fakes as identity_fakes from openstackclient.tests.volume.v2 import fakes as volume_fakes @@ -61,26 +62,24 @@ class TestVolumeCreate(TestVolume): 'status', 'type', ) - datalist = ( - volume_fakes.volume_attachments, - volume_fakes.volume_availability_zone, - volume_fakes.volume_description, - volume_fakes.volume_id, - volume_fakes.volume_name, - volume_fakes.volume_metadata_str, - volume_fakes.volume_size, - volume_fakes.volume_snapshot_id, - volume_fakes.volume_status, - volume_fakes.volume_type, - ) def setUp(self): super(TestVolumeCreate, self).setUp() - self.volumes_mock.create.return_value = fakes.FakeResource( - None, - copy.deepcopy(volume_fakes.VOLUME), - loaded=True, + self.new_volume = volume_fakes.FakeVolume.create_one_volume() + self.volumes_mock.create.return_value = self.new_volume + + self.datalist = ( + self.new_volume.attachments, + self.new_volume.availability_zone, + self.new_volume.description, + self.new_volume.id, + self.new_volume.name, + utils.format_dict(self.new_volume.metadata), + self.new_volume.size, + self.new_volume.snapshot_id, + self.new_volume.status, + self.new_volume.volume_type, ) # Get the command object to test @@ -88,12 +87,12 @@ class TestVolumeCreate(TestVolume): def test_volume_create_min_options(self): arglist = [ - '--size', str(volume_fakes.volume_size), - volume_fakes.volume_name, + '--size', str(self.new_volume.size), + self.new_volume.name, ] verifylist = [ - ('size', volume_fakes.volume_size), - ('name', volume_fakes.volume_name), + ('size', self.new_volume.size), + ('name', self.new_volume.name), ] parsed_args = self.check_parser(self.cmd, arglist, verifylist) @@ -101,9 +100,9 @@ class TestVolumeCreate(TestVolume): columns, data = self.cmd.take_action(parsed_args) self.volumes_mock.create.assert_called_with( - size=volume_fakes.volume_size, + size=self.new_volume.size, snapshot_id=None, - name=volume_fakes.volume_name, + name=self.new_volume.name, description=None, volume_type=None, user_id=None, @@ -119,18 +118,18 @@ class TestVolumeCreate(TestVolume): def test_volume_create_options(self): arglist = [ - '--size', str(volume_fakes.volume_size), - '--description', volume_fakes.volume_description, - '--type', volume_fakes.volume_type, - '--availability-zone', volume_fakes.volume_availability_zone, - volume_fakes.volume_name, + '--size', str(self.new_volume.size), + '--description', self.new_volume.description, + '--type', self.new_volume.volume_type, + '--availability-zone', self.new_volume.availability_zone, + self.new_volume.name, ] verifylist = [ - ('size', volume_fakes.volume_size), - ('description', volume_fakes.volume_description), - ('type', volume_fakes.volume_type), - ('availability_zone', volume_fakes.volume_availability_zone), - ('name', volume_fakes.volume_name), + ('size', self.new_volume.size), + ('description', self.new_volume.description), + ('type', self.new_volume.volume_type), + ('availability_zone', self.new_volume.availability_zone), + ('name', self.new_volume.name), ] parsed_args = self.check_parser(self.cmd, arglist, verifylist) @@ -138,14 +137,14 @@ class TestVolumeCreate(TestVolume): columns, data = self.cmd.take_action(parsed_args) self.volumes_mock.create.assert_called_with( - size=volume_fakes.volume_size, + size=self.new_volume.size, snapshot_id=None, - name=volume_fakes.volume_name, - description=volume_fakes.volume_description, - volume_type=volume_fakes.volume_type, + name=self.new_volume.name, + description=self.new_volume.description, + volume_type=self.new_volume.volume_type, user_id=None, project_id=None, - availability_zone=volume_fakes.volume_availability_zone, + availability_zone=self.new_volume.availability_zone, metadata=None, imageRef=None, source_volid=None @@ -169,16 +168,16 @@ class TestVolumeCreate(TestVolume): ) arglist = [ - '--size', str(volume_fakes.volume_size), + '--size', str(self.new_volume.size), '--project', identity_fakes.project_id, '--user', identity_fakes.user_id, - volume_fakes.volume_name, + self.new_volume.name, ] verifylist = [ - ('size', volume_fakes.volume_size), + ('size', self.new_volume.size), ('project', identity_fakes.project_id), ('user', identity_fakes.user_id), - ('name', volume_fakes.volume_name), + ('name', self.new_volume.name), ] parsed_args = self.check_parser(self.cmd, arglist, verifylist) @@ -186,9 +185,9 @@ class TestVolumeCreate(TestVolume): columns, data = self.cmd.take_action(parsed_args) self.volumes_mock.create.assert_called_with( - size=volume_fakes.volume_size, + size=self.new_volume.size, snapshot_id=None, - name=volume_fakes.volume_name, + name=self.new_volume.name, description=None, volume_type=None, user_id=identity_fakes.user_id, @@ -217,16 +216,16 @@ class TestVolumeCreate(TestVolume): ) arglist = [ - '--size', str(volume_fakes.volume_size), + '--size', str(self.new_volume.size), '--project', identity_fakes.project_name, '--user', identity_fakes.user_name, - volume_fakes.volume_name, + self.new_volume.name, ] verifylist = [ - ('size', volume_fakes.volume_size), + ('size', self.new_volume.size), ('project', identity_fakes.project_name), ('user', identity_fakes.user_name), - ('name', volume_fakes.volume_name), + ('name', self.new_volume.name), ] parsed_args = self.check_parser(self.cmd, arglist, verifylist) @@ -234,9 +233,9 @@ class TestVolumeCreate(TestVolume): columns, data = self.cmd.take_action(parsed_args) self.volumes_mock.create.assert_called_with( - size=volume_fakes.volume_size, + size=self.new_volume.size, snapshot_id=None, - name=volume_fakes.volume_name, + name=self.new_volume.name, description=None, volume_type=None, user_id=identity_fakes.user_id, @@ -254,13 +253,13 @@ class TestVolumeCreate(TestVolume): arglist = [ '--property', 'Alpha=a', '--property', 'Beta=b', - '--size', str(volume_fakes.volume_size), - volume_fakes.volume_name, + '--size', str(self.new_volume.size), + self.new_volume.name, ] verifylist = [ ('property', {'Alpha': 'a', 'Beta': 'b'}), - ('size', volume_fakes.volume_size), - ('name', volume_fakes.volume_name), + ('size', self.new_volume.size), + ('name', self.new_volume.name), ] parsed_args = self.check_parser(self.cmd, arglist, verifylist) @@ -268,9 +267,9 @@ class TestVolumeCreate(TestVolume): columns, data = self.cmd.take_action(parsed_args) self.volumes_mock.create.assert_called_with( - size=volume_fakes.volume_size, + size=self.new_volume.size, snapshot_id=None, - name=volume_fakes.volume_name, + name=self.new_volume.name, description=None, volume_type=None, user_id=None, @@ -293,13 +292,13 @@ class TestVolumeCreate(TestVolume): arglist = [ '--image', volume_fakes.image_id, - '--size', str(volume_fakes.volume_size), - volume_fakes.volume_name, + '--size', str(self.new_volume.size), + self.new_volume.name, ] verifylist = [ ('image', volume_fakes.image_id), - ('size', volume_fakes.volume_size), - ('name', volume_fakes.volume_name), + ('size', self.new_volume.size), + ('name', self.new_volume.name), ] parsed_args = self.check_parser(self.cmd, arglist, verifylist) @@ -307,9 +306,9 @@ class TestVolumeCreate(TestVolume): columns, data = self.cmd.take_action(parsed_args) self.volumes_mock.create.assert_called_with( - size=volume_fakes.volume_size, + size=self.new_volume.size, snapshot_id=None, - name=volume_fakes.volume_name, + name=self.new_volume.name, description=None, volume_type=None, user_id=None, @@ -332,13 +331,13 @@ class TestVolumeCreate(TestVolume): arglist = [ '--image', volume_fakes.image_name, - '--size', str(volume_fakes.volume_size), - volume_fakes.volume_name, + '--size', str(self.new_volume.size), + self.new_volume.name, ] verifylist = [ ('image', volume_fakes.image_name), - ('size', volume_fakes.volume_size), - ('name', volume_fakes.volume_name), + ('size', self.new_volume.size), + ('name', self.new_volume.name), ] parsed_args = self.check_parser(self.cmd, arglist, verifylist) @@ -346,9 +345,9 @@ class TestVolumeCreate(TestVolume): columns, data = self.cmd.take_action(parsed_args) self.volumes_mock.create.assert_called_with( - size=volume_fakes.volume_size, + size=self.new_volume.size, snapshot_id=None, - name=volume_fakes.volume_name, + name=self.new_volume.name, description=None, volume_type=None, user_id=None,