summaryrefslogtreecommitdiff
path: root/openstackclient/tests/unit/volume/v2
diff options
context:
space:
mode:
authorStephen Finucane <sfinucan@redhat.com>2023-05-08 10:54:22 +0100
committerStephen Finucane <sfinucan@redhat.com>2023-05-10 10:51:30 +0100
commit35ba1d8f1304d3255b96b704d524666ec5b6fea2 (patch)
tree6d4ab560d4086e8b1a1f935b8531d7e85550cc36 /openstackclient/tests/unit/volume/v2
parent28ffa2bf9f017212da5eb84b0cf74df62e2f5eb9 (diff)
downloadpython-openstackclient-35ba1d8f1304d3255b96b704d524666ec5b6fea2.tar.gz
Blacken openstackclient.volume
Black used with the '-l 79 -S' flags. A future change will ignore this commit in git-blame history by adding a 'git-blame-ignore-revs' file. Change-Id: Ic318617c67ab7ce6527f9016b759a1d4b0b80802 Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
Diffstat (limited to 'openstackclient/tests/unit/volume/v2')
-rw-r--r--openstackclient/tests/unit/volume/v2/fakes.py4
-rw-r--r--openstackclient/tests/unit/volume/v2/test_backup_record.py9
-rw-r--r--openstackclient/tests/unit/volume/v2/test_consistency_group.py269
-rw-r--r--openstackclient/tests/unit/volume/v2/test_consistency_group_snapshot.py126
-rw-r--r--openstackclient/tests/unit/volume/v2/test_qos_specs.py153
-rw-r--r--openstackclient/tests/unit/volume/v2/test_service.py95
-rw-r--r--openstackclient/tests/unit/volume/v2/test_type.py324
-rw-r--r--openstackclient/tests/unit/volume/v2/test_volume.py617
-rw-r--r--openstackclient/tests/unit/volume/v2/test_volume_backend.py34
-rw-r--r--openstackclient/tests/unit/volume/v2/test_volume_backup.py333
-rw-r--r--openstackclient/tests/unit/volume/v2/test_volume_host.py9
-rw-r--r--openstackclient/tests/unit/volume/v2/test_volume_snapshot.py308
-rw-r--r--openstackclient/tests/unit/volume/v2/test_volume_transfer_request.py119
13 files changed, 1248 insertions, 1152 deletions
diff --git a/openstackclient/tests/unit/volume/v2/fakes.py b/openstackclient/tests/unit/volume/v2/fakes.py
index a3ef142f..81e3a8a2 100644
--- a/openstackclient/tests/unit/volume/v2/fakes.py
+++ b/openstackclient/tests/unit/volume/v2/fakes.py
@@ -1182,12 +1182,12 @@ class FakeLimits(object):
@property
def absolute(self):
- for (name, value) in self.absolute_limits_attrs.items():
+ for name, value in self.absolute_limits_attrs.items():
yield FakeAbsoluteLimit(name, value)
def absolute_limits(self):
reference_data = []
- for (name, value) in self.absolute_limits_attrs.items():
+ for name, value in self.absolute_limits_attrs.items():
reference_data.append((name, value))
return reference_data
diff --git a/openstackclient/tests/unit/volume/v2/test_backup_record.py b/openstackclient/tests/unit/volume/v2/test_backup_record.py
index aa9a25a2..4933af16 100644
--- a/openstackclient/tests/unit/volume/v2/test_backup_record.py
+++ b/openstackclient/tests/unit/volume/v2/test_backup_record.py
@@ -17,7 +17,6 @@ from openstackclient.volume.v2 import backup_record
class TestBackupRecord(volume_fakes.TestVolume):
-
def setUp(self):
super().setUp()
@@ -26,7 +25,6 @@ class TestBackupRecord(volume_fakes.TestVolume):
class TestBackupRecordExport(TestBackupRecord):
-
new_backup = volume_fakes.create_one_backup(
attrs={'volume_id': 'a54708a2-0388-4476-a909-09579f885c25'},
)
@@ -81,7 +79,6 @@ class TestBackupRecordExport(TestBackupRecord):
class TestBackupRecordImport(TestBackupRecord):
-
new_backup = volume_fakes.create_one_backup(
attrs={'volume_id': 'a54708a2-0388-4476-a909-09579f885c25'},
)
@@ -101,8 +98,10 @@ class TestBackupRecordImport(TestBackupRecord):
"fake_backup_record_data",
]
verifylist = [
- ("backup_service",
- "cinder.backup.drivers.swift.SwiftBackupDriver"),
+ (
+ "backup_service",
+ "cinder.backup.drivers.swift.SwiftBackupDriver",
+ ),
("backup_metadata", "fake_backup_record_data"),
]
diff --git a/openstackclient/tests/unit/volume/v2/test_consistency_group.py b/openstackclient/tests/unit/volume/v2/test_consistency_group.py
index c5537ed8..52376204 100644
--- a/openstackclient/tests/unit/volume/v2/test_consistency_group.py
+++ b/openstackclient/tests/unit/volume/v2/test_consistency_group.py
@@ -24,21 +24,19 @@ from openstackclient.volume.v2 import consistency_group
class TestConsistencyGroup(volume_fakes.TestVolume):
-
def setUp(self):
super().setUp()
# Get a shortcut to the TransferManager Mock
self.consistencygroups_mock = (
- self.app.client_manager.volume.consistencygroups)
+ self.app.client_manager.volume.consistencygroups
+ )
self.consistencygroups_mock.reset_mock()
- self.cgsnapshots_mock = (
- self.app.client_manager.volume.cgsnapshots)
+ self.cgsnapshots_mock = self.app.client_manager.volume.cgsnapshots
self.cgsnapshots_mock.reset_mock()
- self.volumes_mock = (
- self.app.client_manager.volume.volumes)
+ self.volumes_mock = self.app.client_manager.volume.volumes
self.volumes_mock.reset_mock()
self.types_mock = self.app.client_manager.volume.volume_types
@@ -46,17 +44,16 @@ class TestConsistencyGroup(volume_fakes.TestVolume):
class TestConsistencyGroupAddVolume(TestConsistencyGroup):
-
_consistency_group = volume_fakes.create_one_consistency_group()
def setUp(self):
super().setUp()
- self.consistencygroups_mock.get.return_value = (
- self._consistency_group)
+ self.consistencygroups_mock.get.return_value = self._consistency_group
# Get the command object to test
- self.cmd = \
- consistency_group.AddVolumeToConsistencyGroup(self.app, None)
+ self.cmd = consistency_group.AddVolumeToConsistencyGroup(
+ self.app, None
+ )
def test_add_one_volume_to_consistency_group(self):
volume = volume_fakes.create_one_volume()
@@ -78,8 +75,7 @@ class TestConsistencyGroupAddVolume(TestConsistencyGroup):
'add_volumes': volume.id,
}
self.consistencygroups_mock.update.assert_called_once_with(
- self._consistency_group.id,
- **kwargs
+ self._consistency_group.id, **kwargs
)
self.assertIsNone(result)
@@ -104,14 +100,14 @@ class TestConsistencyGroupAddVolume(TestConsistencyGroup):
'add_volumes': volumes[0].id + ',' + volumes[1].id,
}
self.consistencygroups_mock.update.assert_called_once_with(
- self._consistency_group.id,
- **kwargs
+ self._consistency_group.id, **kwargs
)
self.assertIsNone(result)
@mock.patch.object(consistency_group.LOG, 'error')
def test_add_multiple_volumes_to_consistency_group_with_exception(
- self, mock_error,
+ self,
+ mock_error,
):
volume = volume_fakes.create_one_volume()
arglist = [
@@ -126,20 +122,22 @@ class TestConsistencyGroupAddVolume(TestConsistencyGroup):
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
- find_mock_result = [volume,
- exceptions.CommandError,
- self._consistency_group]
- with mock.patch.object(utils, 'find_resource',
- side_effect=find_mock_result) as find_mock:
+ find_mock_result = [
+ volume,
+ exceptions.CommandError,
+ self._consistency_group,
+ ]
+ with mock.patch.object(
+ utils, 'find_resource', side_effect=find_mock_result
+ ) as find_mock:
result = self.cmd.take_action(parsed_args)
mock_error.assert_called_with("1 of 2 volumes failed to add.")
self.assertIsNone(result)
- find_mock.assert_any_call(self.consistencygroups_mock,
- self._consistency_group.id)
- find_mock.assert_any_call(self.volumes_mock,
- volume.id)
- find_mock.assert_any_call(self.volumes_mock,
- 'unexist_volume')
+ find_mock.assert_any_call(
+ self.consistencygroups_mock, self._consistency_group.id
+ )
+ find_mock.assert_any_call(self.volumes_mock, volume.id)
+ find_mock.assert_any_call(self.volumes_mock, 'unexist_volume')
self.assertEqual(3, find_mock.call_count)
self.consistencygroups_mock.update.assert_called_once_with(
self._consistency_group.id, add_volumes=volume.id
@@ -147,7 +145,6 @@ class TestConsistencyGroupAddVolume(TestConsistencyGroup):
class TestConsistencyGroupCreate(TestConsistencyGroup):
-
volume_type = volume_fakes.create_one_volume_type()
new_consistency_group = volume_fakes.create_one_consistency_group()
consistency_group_snapshot = (
@@ -176,22 +173,28 @@ class TestConsistencyGroupCreate(TestConsistencyGroup):
def setUp(self):
super().setUp()
self.consistencygroups_mock.create.return_value = (
- self.new_consistency_group)
+ self.new_consistency_group
+ )
self.consistencygroups_mock.create_from_src.return_value = (
- self.new_consistency_group)
+ self.new_consistency_group
+ )
self.consistencygroups_mock.get.return_value = (
- self.new_consistency_group)
+ self.new_consistency_group
+ )
self.types_mock.get.return_value = self.volume_type
self.cgsnapshots_mock.get.return_value = (
- self.consistency_group_snapshot)
+ self.consistency_group_snapshot
+ )
# Get the command object to test
self.cmd = consistency_group.CreateConsistencyGroup(self.app, None)
def test_consistency_group_create(self):
arglist = [
- '--volume-type', self.volume_type.id,
- '--description', self.new_consistency_group.description,
+ '--volume-type',
+ self.volume_type.id,
+ '--description',
+ self.new_consistency_group.description,
'--availability-zone',
self.new_consistency_group.availability_zone,
self.new_consistency_group.name,
@@ -199,16 +202,17 @@ class TestConsistencyGroupCreate(TestConsistencyGroup):
verifylist = [
('volume_type', self.volume_type.id),
('description', self.new_consistency_group.description),
- ('availability_zone',
- self.new_consistency_group.availability_zone),
+ (
+ 'availability_zone',
+ self.new_consistency_group.availability_zone,
+ ),
('name', self.new_consistency_group.name),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
columns, data = self.cmd.take_action(parsed_args)
- self.types_mock.get.assert_called_once_with(
- self.volume_type.id)
+ self.types_mock.get.assert_called_once_with(self.volume_type.id)
self.consistencygroups_mock.get.assert_not_called()
self.consistencygroups_mock.create.assert_called_once_with(
self.volume_type.id,
@@ -222,23 +226,26 @@ class TestConsistencyGroupCreate(TestConsistencyGroup):
def test_consistency_group_create_without_name(self):
arglist = [
- '--volume-type', self.volume_type.id,
- '--description', self.new_consistency_group.description,
+ '--volume-type',
+ self.volume_type.id,
+ '--description',
+ self.new_consistency_group.description,
'--availability-zone',
self.new_consistency_group.availability_zone,
]
verifylist = [
('volume_type', self.volume_type.id),
('description', self.new_consistency_group.description),
- ('availability_zone',
- self.new_consistency_group.availability_zone),
+ (
+ 'availability_zone',
+ self.new_consistency_group.availability_zone,
+ ),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
columns, data = self.cmd.take_action(parsed_args)
- self.types_mock.get.assert_called_once_with(
- self.volume_type.id)
+ self.types_mock.get.assert_called_once_with(self.volume_type.id)
self.consistencygroups_mock.get.assert_not_called()
self.consistencygroups_mock.create.assert_called_once_with(
self.volume_type.id,
@@ -252,8 +259,10 @@ class TestConsistencyGroupCreate(TestConsistencyGroup):
def test_consistency_group_create_from_source(self):
arglist = [
- '--consistency-group-source', self.new_consistency_group.id,
- '--description', self.new_consistency_group.description,
+ '--consistency-group-source',
+ self.new_consistency_group.id,
+ '--description',
+ self.new_consistency_group.description,
self.new_consistency_group.name,
]
verifylist = [
@@ -267,7 +276,8 @@ class TestConsistencyGroupCreate(TestConsistencyGroup):
self.types_mock.get.assert_not_called()
self.consistencygroups_mock.get.assert_called_once_with(
- self.new_consistency_group.id)
+ self.new_consistency_group.id
+ )
self.consistencygroups_mock.create_from_src.assert_called_with(
None,
self.new_consistency_group.id,
@@ -280,8 +290,10 @@ class TestConsistencyGroupCreate(TestConsistencyGroup):
def test_consistency_group_create_from_snapshot(self):
arglist = [
- '--consistency-group-snapshot', self.consistency_group_snapshot.id,
- '--description', self.new_consistency_group.description,
+ '--consistency-group-snapshot',
+ self.consistency_group_snapshot.id,
+ '--description',
+ self.new_consistency_group.description,
self.new_consistency_group.name,
]
verifylist = [
@@ -295,7 +307,8 @@ class TestConsistencyGroupCreate(TestConsistencyGroup):
self.types_mock.get.assert_not_called()
self.cgsnapshots_mock.get.assert_called_once_with(
- self.consistency_group_snapshot.id)
+ self.consistency_group_snapshot.id
+ )
self.consistencygroups_mock.create_from_src.assert_called_with(
self.consistency_group_snapshot.id,
None,
@@ -308,9 +321,7 @@ class TestConsistencyGroupCreate(TestConsistencyGroup):
class TestConsistencyGroupDelete(TestConsistencyGroup):
-
- consistency_groups =\
- volume_fakes.create_consistency_groups(count=2)
+ consistency_groups = volume_fakes.create_consistency_groups(count=2)
def setUp(self):
super().setUp()
@@ -324,18 +335,15 @@ class TestConsistencyGroupDelete(TestConsistencyGroup):
self.cmd = consistency_group.DeleteConsistencyGroup(self.app, None)
def test_consistency_group_delete(self):
- arglist = [
- self.consistency_groups[0].id
- ]
- verifylist = [
- ("consistency_groups", [self.consistency_groups[0].id])
- ]
+ arglist = [self.consistency_groups[0].id]
+ verifylist = [("consistency_groups", [self.consistency_groups[0].id])]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
result = self.cmd.take_action(parsed_args)
self.consistencygroups_mock.delete.assert_called_with(
- self.consistency_groups[0].id, False)
+ self.consistency_groups[0].id, False
+ )
self.assertIsNone(result)
def test_consistency_group_delete_with_force(self):
@@ -345,14 +353,15 @@ class TestConsistencyGroupDelete(TestConsistencyGroup):
]
verifylist = [
('force', True),
- ("consistency_groups", [self.consistency_groups[0].id])
+ ("consistency_groups", [self.consistency_groups[0].id]),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
result = self.cmd.take_action(parsed_args)
self.consistencygroups_mock.delete.assert_called_with(
- self.consistency_groups[0].id, True)
+ self.consistency_groups[0].id, True
+ )
self.assertIsNone(result)
def test_delete_multiple_consistency_groups(self):
@@ -383,21 +392,27 @@ class TestConsistencyGroupDelete(TestConsistencyGroup):
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
- find_mock_result = [self.consistency_groups[0],
- exceptions.CommandError]
- with mock.patch.object(utils, 'find_resource',
- side_effect=find_mock_result) as find_mock:
+ find_mock_result = [
+ self.consistency_groups[0],
+ exceptions.CommandError,
+ ]
+ with mock.patch.object(
+ utils, 'find_resource', side_effect=find_mock_result
+ ) as find_mock:
try:
self.cmd.take_action(parsed_args)
self.fail('CommandError should be raised.')
except exceptions.CommandError as e:
- self.assertEqual('1 of 2 consistency groups failed to delete.',
- str(e))
+ self.assertEqual(
+ '1 of 2 consistency groups failed to delete.', str(e)
+ )
- find_mock.assert_any_call(self.consistencygroups_mock,
- self.consistency_groups[0].id)
- find_mock.assert_any_call(self.consistencygroups_mock,
- 'unexist_consistency_group')
+ find_mock.assert_any_call(
+ self.consistencygroups_mock, self.consistency_groups[0].id
+ )
+ find_mock.assert_any_call(
+ self.consistencygroups_mock, 'unexist_consistency_group'
+ )
self.assertEqual(2, find_mock.call_count)
self.consistencygroups_mock.delete.assert_called_once_with(
@@ -406,7 +421,6 @@ class TestConsistencyGroupDelete(TestConsistencyGroup):
class TestConsistencyGroupList(TestConsistencyGroup):
-
consistency_groups = volume_fakes.create_consistency_groups(count=2)
columns = [
@@ -424,21 +438,25 @@ class TestConsistencyGroupList(TestConsistencyGroup):
]
data = []
for c in consistency_groups:
- data.append((
- c.id,
- c.status,
- c.name,
- ))
+ data.append(
+ (
+ c.id,
+ c.status,
+ c.name,
+ )
+ )
data_long = []
for c in consistency_groups:
- data_long.append((
- c.id,
- c.status,
- c.availability_zone,
- c.name,
- c.description,
- format_columns.ListColumn(c.volume_types)
- ))
+ data_long.append(
+ (
+ c.id,
+ c.status,
+ c.availability_zone,
+ c.name,
+ c.description,
+ format_columns.ListColumn(c.volume_types),
+ )
+ )
def setUp(self):
super().setUp()
@@ -458,14 +476,13 @@ class TestConsistencyGroupList(TestConsistencyGroup):
columns, data = self.cmd.take_action(parsed_args)
self.consistencygroups_mock.list.assert_called_once_with(
- detailed=True, search_opts={'all_tenants': False})
+ detailed=True, search_opts={'all_tenants': False}
+ )
self.assertEqual(self.columns, columns)
self.assertCountEqual(self.data, list(data))
def test_consistency_group_list_with_all_project(self):
- arglist = [
- "--all-projects"
- ]
+ arglist = ["--all-projects"]
verifylist = [
("all_projects", True),
("long", False),
@@ -475,7 +492,8 @@ class TestConsistencyGroupList(TestConsistencyGroup):
columns, data = self.cmd.take_action(parsed_args)
self.consistencygroups_mock.list.assert_called_once_with(
- detailed=True, search_opts={'all_tenants': True})
+ detailed=True, search_opts={'all_tenants': True}
+ )
self.assertEqual(self.columns, columns)
self.assertCountEqual(self.data, list(data))
@@ -492,23 +510,23 @@ class TestConsistencyGroupList(TestConsistencyGroup):
columns, data = self.cmd.take_action(parsed_args)
self.consistencygroups_mock.list.assert_called_once_with(
- detailed=True, search_opts={'all_tenants': False})
+ detailed=True, search_opts={'all_tenants': False}
+ )
self.assertEqual(self.columns_long, columns)
self.assertCountEqual(self.data_long, list(data))
class TestConsistencyGroupRemoveVolume(TestConsistencyGroup):
-
_consistency_group = volume_fakes.create_one_consistency_group()
def setUp(self):
super().setUp()
- self.consistencygroups_mock.get.return_value = (
- self._consistency_group)
+ self.consistencygroups_mock.get.return_value = self._consistency_group
# Get the command object to test
- self.cmd = \
- consistency_group.RemoveVolumeFromConsistencyGroup(self.app, None)
+ self.cmd = consistency_group.RemoveVolumeFromConsistencyGroup(
+ self.app, None
+ )
def test_remove_one_volume_from_consistency_group(self):
volume = volume_fakes.create_one_volume()
@@ -530,8 +548,7 @@ class TestConsistencyGroupRemoveVolume(TestConsistencyGroup):
'remove_volumes': volume.id,
}
self.consistencygroups_mock.update.assert_called_once_with(
- self._consistency_group.id,
- **kwargs
+ self._consistency_group.id, **kwargs
)
self.assertIsNone(result)
@@ -556,8 +573,7 @@ class TestConsistencyGroupRemoveVolume(TestConsistencyGroup):
'remove_volumes': volumes[0].id + ',' + volumes[1].id,
}
self.consistencygroups_mock.update.assert_called_once_with(
- self._consistency_group.id,
- **kwargs
+ self._consistency_group.id, **kwargs
)
self.assertIsNone(result)
@@ -579,20 +595,22 @@ class TestConsistencyGroupRemoveVolume(TestConsistencyGroup):
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
- find_mock_result = [volume,
- exceptions.CommandError,
- self._consistency_group]
- with mock.patch.object(utils, 'find_resource',
- side_effect=find_mock_result) as find_mock:
+ find_mock_result = [
+ volume,
+ exceptions.CommandError,
+ self._consistency_group,
+ ]
+ with mock.patch.object(
+ utils, 'find_resource', side_effect=find_mock_result
+ ) as find_mock:
result = self.cmd.take_action(parsed_args)
mock_error.assert_called_with("1 of 2 volumes failed to remove.")
self.assertIsNone(result)
- find_mock.assert_any_call(self.consistencygroups_mock,
- self._consistency_group.id)
- find_mock.assert_any_call(self.volumes_mock,
- volume.id)
- find_mock.assert_any_call(self.volumes_mock,
- 'unexist_volume')
+ find_mock.assert_any_call(
+ self.consistencygroups_mock, self._consistency_group.id
+ )
+ find_mock.assert_any_call(self.volumes_mock, volume.id)
+ find_mock.assert_any_call(self.volumes_mock, 'unexist_volume')
self.assertEqual(3, find_mock.call_count)
self.consistencygroups_mock.update.assert_called_once_with(
self._consistency_group.id, remove_volumes=volume.id
@@ -600,21 +618,20 @@ class TestConsistencyGroupRemoveVolume(TestConsistencyGroup):
class TestConsistencyGroupSet(TestConsistencyGroup):
-
consistency_group = volume_fakes.create_one_consistency_group()
def setUp(self):
super().setUp()
- self.consistencygroups_mock.get.return_value = (
- self.consistency_group)
+ self.consistencygroups_mock.get.return_value = self.consistency_group
# Get the command object to test
self.cmd = consistency_group.SetConsistencyGroup(self.app, None)
def test_consistency_group_set_name(self):
new_name = 'new_name'
arglist = [
- '--name', new_name,
+ '--name',
+ new_name,
self.consistency_group.id,
]
verifylist = [
@@ -631,15 +648,15 @@ class TestConsistencyGroupSet(TestConsistencyGroup):
'name': new_name,
}
self.consistencygroups_mock.update.assert_called_once_with(
- self.consistency_group.id,
- **kwargs
+ self.consistency_group.id, **kwargs
)
self.assertIsNone(result)
def test_consistency_group_set_description(self):
new_description = 'new_description'
arglist = [
- '--description', new_description,
+ '--description',
+ new_description,
self.consistency_group.id,
]
verifylist = [
@@ -656,8 +673,7 @@ class TestConsistencyGroupSet(TestConsistencyGroup):
'description': new_description,
}
self.consistencygroups_mock.update.assert_called_once_with(
- self.consistency_group.id,
- **kwargs
+ self.consistency_group.id, **kwargs
)
self.assertIsNone(result)
@@ -690,15 +706,12 @@ class TestConsistencyGroupShow(TestConsistencyGroup):
self.cmd = consistency_group.ShowConsistencyGroup(self.app, None)
def test_consistency_group_show(self):
- arglist = [
- self.consistency_group.id
- ]
- verifylist = [
- ("consistency_group", self.consistency_group.id)
- ]
+ arglist = [self.consistency_group.id]
+ verifylist = [("consistency_group", self.consistency_group.id)]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
columns, data = self.cmd.take_action(parsed_args)
self.consistencygroups_mock.get.assert_called_once_with(
- self.consistency_group.id)
+ self.consistency_group.id
+ )
self.assertEqual(self.columns, columns)
self.assertCountEqual(self.data, data)
diff --git a/openstackclient/tests/unit/volume/v2/test_consistency_group_snapshot.py b/openstackclient/tests/unit/volume/v2/test_consistency_group_snapshot.py
index e3c738c8..873f9d0b 100644
--- a/openstackclient/tests/unit/volume/v2/test_consistency_group_snapshot.py
+++ b/openstackclient/tests/unit/volume/v2/test_consistency_group_snapshot.py
@@ -19,21 +19,19 @@ from openstackclient.volume.v2 import consistency_group_snapshot
class TestConsistencyGroupSnapshot(volume_fakes.TestVolume):
-
def setUp(self):
super(TestConsistencyGroupSnapshot, self).setUp()
# Get a shortcut to the TransferManager Mock
- self.cgsnapshots_mock = (
- self.app.client_manager.volume.cgsnapshots)
+ self.cgsnapshots_mock = self.app.client_manager.volume.cgsnapshots
self.cgsnapshots_mock.reset_mock()
self.consistencygroups_mock = (
- self.app.client_manager.volume.consistencygroups)
+ self.app.client_manager.volume.consistencygroups
+ )
self.consistencygroups_mock.reset_mock()
class TestConsistencyGroupSnapshotCreate(TestConsistencyGroupSnapshot):
-
_consistency_group_snapshot = (
volume_fakes.create_one_consistency_group_snapshot()
)
@@ -59,18 +57,21 @@ class TestConsistencyGroupSnapshotCreate(TestConsistencyGroupSnapshot):
def setUp(self):
super(TestConsistencyGroupSnapshotCreate, self).setUp()
self.cgsnapshots_mock.create.return_value = (
- self._consistency_group_snapshot)
- self.consistencygroups_mock.get.return_value = (
- self.consistency_group)
+ self._consistency_group_snapshot
+ )
+ self.consistencygroups_mock.get.return_value = self.consistency_group
# Get the command object to test
- self.cmd = (consistency_group_snapshot.
- CreateConsistencyGroupSnapshot(self.app, None))
+ self.cmd = consistency_group_snapshot.CreateConsistencyGroupSnapshot(
+ self.app, None
+ )
def test_consistency_group_snapshot_create(self):
arglist = [
- '--consistency-group', self.consistency_group.id,
- '--description', self._consistency_group_snapshot.description,
+ '--consistency-group',
+ self.consistency_group.id,
+ '--description',
+ self._consistency_group_snapshot.description,
self._consistency_group_snapshot.name,
]
verifylist = [
@@ -83,7 +84,8 @@ class TestConsistencyGroupSnapshotCreate(TestConsistencyGroupSnapshot):
columns, data = self.cmd.take_action(parsed_args)
self.consistencygroups_mock.get.assert_called_once_with(
- self.consistency_group.id)
+ self.consistency_group.id
+ )
self.cgsnapshots_mock.create.assert_called_once_with(
self.consistency_group.id,
name=self._consistency_group_snapshot.name,
@@ -95,7 +97,8 @@ class TestConsistencyGroupSnapshotCreate(TestConsistencyGroupSnapshot):
def test_consistency_group_snapshot_create_no_consistency_group(self):
arglist = [
- '--description', self._consistency_group_snapshot.description,
+ '--description',
+ self._consistency_group_snapshot.description,
self._consistency_group_snapshot.name,
]
verifylist = [
@@ -107,7 +110,8 @@ class TestConsistencyGroupSnapshotCreate(TestConsistencyGroupSnapshot):
columns, data = self.cmd.take_action(parsed_args)
self.consistencygroups_mock.get.assert_called_once_with(
- self._consistency_group_snapshot.name)
+ self._consistency_group_snapshot.name
+ )
self.cgsnapshots_mock.create.assert_called_once_with(
self.consistency_group.id,
name=self._consistency_group_snapshot.name,
@@ -119,7 +123,6 @@ class TestConsistencyGroupSnapshotCreate(TestConsistencyGroupSnapshot):
class TestConsistencyGroupSnapshotDelete(TestConsistencyGroupSnapshot):
-
consistency_group_snapshots = (
volume_fakes.create_consistency_group_snapshots(count=2)
)
@@ -135,23 +138,25 @@ class TestConsistencyGroupSnapshotDelete(TestConsistencyGroupSnapshot):
self.cgsnapshots_mock.delete.return_value = None
# Get the command object to mock
- self.cmd = (consistency_group_snapshot.
- DeleteConsistencyGroupSnapshot(self.app, None))
+ self.cmd = consistency_group_snapshot.DeleteConsistencyGroupSnapshot(
+ self.app, None
+ )
def test_consistency_group_snapshot_delete(self):
- arglist = [
- self.consistency_group_snapshots[0].id
- ]
+ arglist = [self.consistency_group_snapshots[0].id]
verifylist = [
- ("consistency_group_snapshot",
- [self.consistency_group_snapshots[0].id])
+ (
+ "consistency_group_snapshot",
+ [self.consistency_group_snapshots[0].id],
+ )
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
result = self.cmd.take_action(parsed_args)
self.cgsnapshots_mock.delete.assert_called_once_with(
- self.consistency_group_snapshots[0].id)
+ self.consistency_group_snapshots[0].id
+ )
self.assertIsNone(result)
def test_multiple_consistency_group_snapshots_delete(self):
@@ -173,7 +178,6 @@ class TestConsistencyGroupSnapshotDelete(TestConsistencyGroupSnapshot):
class TestConsistencyGroupSnapshotList(TestConsistencyGroupSnapshot):
-
consistency_group_snapshots = (
volume_fakes.create_consistency_group_snapshots(count=2)
)
@@ -194,32 +198,36 @@ class TestConsistencyGroupSnapshotList(TestConsistencyGroupSnapshot):
]
data = []
for c in consistency_group_snapshots:
- data.append((
- c.id,
- c.status,
- c.name,
- ))
+ data.append(
+ (
+ c.id,
+ c.status,
+ c.name,
+ )
+ )
data_long = []
for c in consistency_group_snapshots:
- data_long.append((
- c.id,
- c.status,
- c.consistencygroup_id,
- c.name,
- c.description,
- c.created_at,
- ))
+ data_long.append(
+ (
+ c.id,
+ c.status,
+ c.consistencygroup_id,
+ c.name,
+ c.description,
+ c.created_at,
+ )
+ )
def setUp(self):
super(TestConsistencyGroupSnapshotList, self).setUp()
self.cgsnapshots_mock.list.return_value = (
- self.consistency_group_snapshots)
+ self.consistency_group_snapshots
+ )
self.consistencygroups_mock.get.return_value = self.consistency_group
# Get the command to test
- self.cmd = (
- consistency_group_snapshot.
- ListConsistencyGroupSnapshot(self.app, None)
+ self.cmd = consistency_group_snapshot.ListConsistencyGroupSnapshot(
+ self.app, None
)
def test_consistency_group_snapshot_list_without_options(self):
@@ -240,7 +248,8 @@ class TestConsistencyGroupSnapshotList(TestConsistencyGroupSnapshot):
'consistencygroup_id': None,
}
self.cgsnapshots_mock.list.assert_called_once_with(
- detailed=True, search_opts=search_opts)
+ detailed=True, search_opts=search_opts
+ )
self.assertEqual(self.columns, columns)
self.assertEqual(self.data, list(data))
@@ -264,15 +273,18 @@ class TestConsistencyGroupSnapshotList(TestConsistencyGroupSnapshot):
'consistencygroup_id': None,
}
self.cgsnapshots_mock.list.assert_called_once_with(
- detailed=True, search_opts=search_opts)
+ detailed=True, search_opts=search_opts
+ )
self.assertEqual(self.columns_long, columns)
self.assertEqual(self.data_long, list(data))
def test_consistency_group_snapshot_list_with_options(self):
arglist = [
"--all-project",
- "--status", self.consistency_group_snapshots[0].status,
- "--consistency-group", self.consistency_group.id,
+ "--status",
+ self.consistency_group_snapshots[0].status,
+ "--consistency-group",
+ self.consistency_group.id,
]
verifylist = [
("all_projects", True),
@@ -290,15 +302,16 @@ class TestConsistencyGroupSnapshotList(TestConsistencyGroupSnapshot):
'consistencygroup_id': self.consistency_group.id,
}
self.consistencygroups_mock.get.assert_called_once_with(
- self.consistency_group.id)
+ self.consistency_group.id
+ )
self.cgsnapshots_mock.list.assert_called_once_with(
- detailed=True, search_opts=search_opts)
+ detailed=True, search_opts=search_opts
+ )
self.assertEqual(self.columns, columns)
self.assertEqual(self.data, list(data))
class TestConsistencyGroupSnapshotShow(TestConsistencyGroupSnapshot):
-
_consistency_group_snapshot = (
volume_fakes.create_one_consistency_group_snapshot()
)
@@ -324,20 +337,21 @@ class TestConsistencyGroupSnapshotShow(TestConsistencyGroupSnapshot):
super(TestConsistencyGroupSnapshotShow, self).setUp()
self.cgsnapshots_mock.get.return_value = (
- self._consistency_group_snapshot)
- self.cmd = (consistency_group_snapshot.
- ShowConsistencyGroupSnapshot(self.app, None))
+ self._consistency_group_snapshot
+ )
+ self.cmd = consistency_group_snapshot.ShowConsistencyGroupSnapshot(
+ self.app, None
+ )
def test_consistency_group_snapshot_show(self):
- arglist = [
- self._consistency_group_snapshot.id
- ]
+ arglist = [self._consistency_group_snapshot.id]
verifylist = [
("consistency_group_snapshot", self._consistency_group_snapshot.id)
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
columns, data = self.cmd.take_action(parsed_args)
self.cgsnapshots_mock.get.assert_called_once_with(
- self._consistency_group_snapshot.id)
+ self._consistency_group_snapshot.id
+ )
self.assertEqual(self.columns, columns)
self.assertEqual(self.data, data)
diff --git a/openstackclient/tests/unit/volume/v2/test_qos_specs.py b/openstackclient/tests/unit/volume/v2/test_qos_specs.py
index 6f258dd5..994bcf96 100644
--- a/openstackclient/tests/unit/volume/v2/test_qos_specs.py
+++ b/openstackclient/tests/unit/volume/v2/test_qos_specs.py
@@ -26,7 +26,6 @@ from openstackclient.volume.v2 import qos_specs
class TestQos(volume_fakes.TestVolume):
-
def setUp(self):
super(TestQos, self).setUp()
@@ -38,7 +37,6 @@ class TestQos(volume_fakes.TestVolume):
class TestQosAssociate(TestQos):
-
volume_type = volume_fakes.create_one_volume_type()
qos_spec = volume_fakes.create_one_qos()
@@ -51,33 +49,23 @@ class TestQosAssociate(TestQos):
self.cmd = qos_specs.AssociateQos(self.app, None)
def test_qos_associate(self):
- arglist = [
- self.qos_spec.id,
- self.volume_type.id
- ]
+ arglist = [self.qos_spec.id, self.volume_type.id]
verifylist = [
('qos_spec', self.qos_spec.id),
- ('volume_type', self.volume_type.id)
+ ('volume_type', self.volume_type.id),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
result = self.cmd.take_action(parsed_args)
self.qos_mock.associate.assert_called_with(
- self.qos_spec.id,
- self.volume_type.id
+ self.qos_spec.id, self.volume_type.id
)
self.assertIsNone(result)
class TestQosCreate(TestQos):
-
- columns = (
- 'consumer',
- 'id',
- 'name',
- 'properties'
- )
+ columns = ('consumer', 'id', 'name', 'properties')
def setUp(self):
super(TestQosCreate, self).setUp()
@@ -89,7 +77,7 @@ class TestQosCreate(TestQos):
self.new_qos_spec.consumer,
self.new_qos_spec.id,
self.new_qos_spec.name,
- format_columns.DictColumn(self.new_qos_spec.specs)
+ format_columns.DictColumn(self.new_qos_spec.specs),
)
# Get the command object to test
@@ -107,8 +95,7 @@ class TestQosCreate(TestQos):
columns, data = self.cmd.take_action(parsed_args)
self.qos_mock.create.assert_called_with(
- self.new_qos_spec.name,
- {'consumer': 'both'}
+ self.new_qos_spec.name, {'consumer': 'both'}
)
self.assertEqual(self.columns, columns)
@@ -116,7 +103,8 @@ class TestQosCreate(TestQos):
def test_qos_create_with_consumer(self):
arglist = [
- '--consumer', self.new_qos_spec.consumer,
+ '--consumer',
+ self.new_qos_spec.consumer,
self.new_qos_spec.name,
]
verifylist = [
@@ -128,8 +116,7 @@ class TestQosCreate(TestQos):
columns, data = self.cmd.take_action(parsed_args)
self.qos_mock.create.assert_called_with(
- self.new_qos_spec.name,
- {'consumer': self.new_qos_spec.consumer}
+ self.new_qos_spec.name, {'consumer': self.new_qos_spec.consumer}
)
self.assertEqual(self.columns, columns)
@@ -137,9 +124,12 @@ class TestQosCreate(TestQos):
def test_qos_create_with_properties(self):
arglist = [
- '--consumer', self.new_qos_spec.consumer,
- '--property', 'foo=bar',
- '--property', 'iops=9001',
+ '--consumer',
+ self.new_qos_spec.consumer,
+ '--property',
+ 'foo=bar',
+ '--property',
+ 'iops=9001',
self.new_qos_spec.name,
]
verifylist = [
@@ -153,9 +143,11 @@ class TestQosCreate(TestQos):
self.qos_mock.create.assert_called_with(
self.new_qos_spec.name,
- {'consumer': self.new_qos_spec.consumer,
- 'foo': 'bar',
- 'iops': '9001'}
+ {
+ 'consumer': self.new_qos_spec.consumer,
+ 'foo': 'bar',
+ 'iops': '9001',
+ },
)
self.assertEqual(self.columns, columns)
@@ -163,47 +155,33 @@ class TestQosCreate(TestQos):
class TestQosDelete(TestQos):
-
qos_specs = volume_fakes.create_qoses(count=2)
def setUp(self):
super(TestQosDelete, self).setUp()
- self.qos_mock.get = (
- volume_fakes.get_qoses(self.qos_specs))
+ self.qos_mock.get = volume_fakes.get_qoses(self.qos_specs)
# Get the command object to test
self.cmd = qos_specs.DeleteQos(self.app, None)
def test_qos_delete(self):
- arglist = [
- self.qos_specs[0].id
- ]
- verifylist = [
- ('qos_specs', [self.qos_specs[0].id])
- ]
+ arglist = [self.qos_specs[0].id]
+ verifylist = [('qos_specs', [self.qos_specs[0].id])]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
result = self.cmd.take_action(parsed_args)
- self.qos_mock.delete.assert_called_with(
- self.qos_specs[0].id, False)
+ self.qos_mock.delete.assert_called_with(self.qos_specs[0].id, False)
self.assertIsNone(result)
def test_qos_delete_with_force(self):
- arglist = [
- '--force',
- self.qos_specs[0].id
- ]
- verifylist = [
- ('force', True),
- ('qos_specs', [self.qos_specs[0].id])
- ]
+ arglist = ['--force', self.qos_specs[0].id]
+ verifylist = [('force', True), ('qos_specs', [self.qos_specs[0].id])]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
result = self.cmd.take_action(parsed_args)
- self.qos_mock.delete.assert_called_with(
- self.qos_specs[0].id, True)
+ self.qos_mock.delete.assert_called_with(self.qos_specs[0].id, True)
self.assertIsNone(result)
def test_delete_multiple_qoses(self):
@@ -235,14 +213,16 @@ class TestQosDelete(TestQos):
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
find_mock_result = [self.qos_specs[0], exceptions.CommandError]
- with mock.patch.object(utils, 'find_resource',
- side_effect=find_mock_result) as find_mock:
+ with mock.patch.object(
+ utils, 'find_resource', side_effect=find_mock_result
+ ) as find_mock:
try:
self.cmd.take_action(parsed_args)
self.fail('CommandError should be raised.')
except exceptions.CommandError as e:
self.assertEqual(
- '1 of 2 QoS specifications failed to delete.', str(e))
+ '1 of 2 QoS specifications failed to delete.', str(e)
+ )
find_mock.assert_any_call(self.qos_mock, self.qos_specs[0].id)
find_mock.assert_any_call(self.qos_mock, 'unexist_qos')
@@ -254,7 +234,6 @@ class TestQosDelete(TestQos):
class TestQosDisassociate(TestQos):
-
volume_type = volume_fakes.create_one_volume_type()
qos_spec = volume_fakes.create_one_qos()
@@ -268,7 +247,8 @@ class TestQosDisassociate(TestQos):
def test_qos_disassociate_with_volume_type(self):
arglist = [
- '--volume-type', self.volume_type.id,
+ '--volume-type',
+ self.volume_type.id,
self.qos_spec.id,
]
verifylist = [
@@ -280,8 +260,7 @@ class TestQosDisassociate(TestQos):
result = self.cmd.take_action(parsed_args)
self.qos_mock.disassociate.assert_called_with(
- self.qos_spec.id,
- self.volume_type.id
+ self.qos_spec.id, self.volume_type.id
)
self.assertIsNone(result)
@@ -290,9 +269,7 @@ class TestQosDisassociate(TestQos):
'--all',
self.qos_spec.id,
]
- verifylist = [
- ('qos_spec', self.qos_spec.id)
- ]
+ verifylist = [('qos_spec', self.qos_spec.id)]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
result = self.cmd.take_action(parsed_args)
@@ -302,7 +279,6 @@ class TestQosDisassociate(TestQos):
class TestQosList(TestQos):
-
qos_specs = volume_fakes.create_qoses(count=2)
qos_association = volume_fakes.create_one_qos_association()
@@ -315,13 +291,15 @@ class TestQosList(TestQos):
)
data = []
for q in qos_specs:
- data.append((
- q.id,
- q.name,
- q.consumer,
- format_columns.ListColumn([qos_association.name]),
- format_columns.DictColumn(q.specs),
- ))
+ data.append(
+ (
+ q.id,
+ q.name,
+ q.consumer,
+ format_columns.ListColumn([qos_association.name]),
+ format_columns.DictColumn(q.specs),
+ )
+ )
def setUp(self):
super(TestQosList, self).setUp()
@@ -373,7 +351,6 @@ class TestQosList(TestQos):
class TestQosSet(TestQos):
-
qos_spec = volume_fakes.create_one_qos()
def setUp(self):
@@ -385,8 +362,10 @@ class TestQosSet(TestQos):
def test_qos_set_with_properties_with_id(self):
arglist = [
- '--property', 'foo=bar',
- '--property', 'iops=9001',
+ '--property',
+ 'foo=bar',
+ '--property',
+ 'iops=9001',
self.qos_spec.id,
]
verifylist = [
@@ -398,24 +377,16 @@ class TestQosSet(TestQos):
result = self.cmd.take_action(parsed_args)
self.qos_mock.set_keys.assert_called_with(
- self.qos_spec.id,
- self.qos_spec.specs
+ self.qos_spec.id, self.qos_spec.specs
)
self.assertIsNone(result)
class TestQosShow(TestQos):
-
qos_spec = volume_fakes.create_one_qos()
qos_association = volume_fakes.create_one_qos_association()
- columns = (
- 'associations',
- 'consumer',
- 'id',
- 'name',
- 'properties'
- )
+ columns = ('associations', 'consumer', 'id', 'name', 'properties')
data = (
format_columns.ListColumn([qos_association.name]),
qos_spec.consumer,
@@ -434,26 +405,19 @@ class TestQosShow(TestQos):
self.cmd = qos_specs.ShowQos(self.app, None)
def test_qos_show(self):
- arglist = [
- self.qos_spec.id
- ]
- verifylist = [
- ('qos_spec', self.qos_spec.id)
- ]
+ arglist = [self.qos_spec.id]
+ verifylist = [('qos_spec', self.qos_spec.id)]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
columns, data = self.cmd.take_action(parsed_args)
- self.qos_mock.get.assert_called_with(
- self.qos_spec.id
- )
+ self.qos_mock.get.assert_called_with(self.qos_spec.id)
self.assertEqual(self.columns, columns)
self.assertCountEqual(self.data, tuple(data))
class TestQosUnset(TestQos):
-
qos_spec = volume_fakes.create_one_qos()
def setUp(self):
@@ -465,8 +429,10 @@ class TestQosUnset(TestQos):
def test_qos_unset_with_properties(self):
arglist = [
- '--property', 'iops',
- '--property', 'foo',
+ '--property',
+ 'iops',
+ '--property',
+ 'foo',
self.qos_spec.id,
]
verifylist = [
@@ -478,7 +444,6 @@ class TestQosUnset(TestQos):
result = self.cmd.take_action(parsed_args)
self.qos_mock.unset_keys.assert_called_with(
- self.qos_spec.id,
- ['iops', 'foo']
+ self.qos_spec.id, ['iops', 'foo']
)
self.assertIsNone(result)
diff --git a/openstackclient/tests/unit/volume/v2/test_service.py b/openstackclient/tests/unit/volume/v2/test_service.py
index e9e39f41..90fd08ba 100644
--- a/openstackclient/tests/unit/volume/v2/test_service.py
+++ b/openstackclient/tests/unit/volume/v2/test_service.py
@@ -19,7 +19,6 @@ from openstackclient.volume.v2 import service
class TestService(volume_fakes.TestVolume):
-
def setUp(self):
super().setUp()
@@ -29,7 +28,6 @@ class TestService(volume_fakes.TestVolume):
class TestServiceList(TestService):
-
# The service to be listed
services = volume_fakes.create_one_service()
@@ -43,8 +41,10 @@ class TestServiceList(TestService):
def test_service_list(self):
arglist = [
- '--host', self.services.host,
- '--service', self.services.binary,
+ '--host',
+ self.services.host,
+ '--service',
+ self.services.binary,
]
verifylist = [
('host', self.services.host),
@@ -69,14 +69,16 @@ class TestServiceList(TestService):
# confirming if all expected columns are present in the result.
self.assertEqual(expected_columns, columns)
- datalist = ((
- self.services.binary,
- self.services.host,
- self.services.zone,
- self.services.status,
- self.services.state,
- self.services.updated_at,
- ), )
+ datalist = (
+ (
+ self.services.binary,
+ self.services.host,
+ self.services.zone,
+ self.services.status,
+ self.services.state,
+ self.services.updated_at,
+ ),
+ )
# confirming if all expected values are present in the result.
self.assertEqual(datalist, tuple(data))
@@ -89,19 +91,20 @@ class TestServiceList(TestService):
# checking if prohibited columns are present in output
self.assertNotIn("Disabled Reason", columns)
- self.assertNotIn(self.services.disabled_reason,
- tuple(data))
+ self.assertNotIn(self.services.disabled_reason, tuple(data))
def test_service_list_with_long_option(self):
arglist = [
- '--host', self.services.host,
- '--service', self.services.binary,
- '--long'
+ '--host',
+ self.services.host,
+ '--service',
+ self.services.binary,
+ '--long',
]
verifylist = [
('host', self.services.host),
('service', self.services.binary),
- ('long', True)
+ ('long', True),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -117,21 +120,23 @@ class TestServiceList(TestService):
'Status',
'State',
'Updated At',
- 'Disabled Reason'
+ 'Disabled Reason',
]
# confirming if all expected columns are present in the result.
self.assertEqual(expected_columns, columns)
- datalist = ((
- self.services.binary,
- self.services.host,
- self.services.zone,
- self.services.status,
- self.services.state,
- self.services.updated_at,
- self.services.disabled_reason,
- ), )
+ datalist = (
+ (
+ self.services.binary,
+ self.services.host,
+ self.services.zone,
+ self.services.status,
+ self.services.state,
+ self.services.updated_at,
+ self.services.disabled_reason,
+ ),
+ )
# confirming if all expected values are present in the result.
self.assertEqual(datalist, tuple(data))
@@ -143,7 +148,6 @@ class TestServiceList(TestService):
class TestServiceSet(TestService):
-
service = volume_fakes.create_one_service()
def setUp(self):
@@ -188,8 +192,7 @@ class TestServiceSet(TestService):
result = self.cmd.take_action(parsed_args)
self.service_mock.enable.assert_called_with(
- self.service.host,
- self.service.binary
+ self.service.host, self.service.binary
)
self.service_mock.disable.assert_not_called()
self.service_mock.disable_log_reason.assert_not_called()
@@ -211,8 +214,7 @@ class TestServiceSet(TestService):
result = self.cmd.take_action(parsed_args)
self.service_mock.disable.assert_called_with(
- self.service.host,
- self.service.binary
+ self.service.host, self.service.binary
)
self.service_mock.enable.assert_not_called()
self.service_mock.disable_log_reason.assert_not_called()
@@ -222,7 +224,8 @@ class TestServiceSet(TestService):
reason = 'earthquake'
arglist = [
'--disable',
- '--disable-reason', reason,
+ '--disable-reason',
+ reason,
self.service.host,
self.service.binary,
]
@@ -237,16 +240,15 @@ class TestServiceSet(TestService):
result = self.cmd.take_action(parsed_args)
self.service_mock.disable_log_reason.assert_called_with(
- self.service.host,
- self.service.binary,
- reason
+ self.service.host, self.service.binary, reason
)
self.assertIsNone(result)
def test_service_set_only_with_disable_reason(self):
reason = 'earthquake'
arglist = [
- '--disable-reason', reason,
+ '--disable-reason',
+ reason,
self.service.host,
self.service.binary,
]
@@ -260,14 +262,18 @@ class TestServiceSet(TestService):
self.cmd.take_action(parsed_args)
self.fail("CommandError should be raised.")
except exceptions.CommandError as e:
- self.assertEqual("Cannot specify option --disable-reason without "
- "--disable specified.", str(e))
+ self.assertEqual(
+ "Cannot specify option --disable-reason without "
+ "--disable specified.",
+ str(e),
+ )
def test_service_set_enable_with_disable_reason(self):
reason = 'earthquake'
arglist = [
'--enable',
- '--disable-reason', reason,
+ '--disable-reason',
+ reason,
self.service.host,
self.service.binary,
]
@@ -282,5 +288,8 @@ class TestServiceSet(TestService):
self.cmd.take_action(parsed_args)
self.fail("CommandError should be raised.")
except exceptions.CommandError as e:
- self.assertEqual("Cannot specify option --disable-reason without "
- "--disable specified.", str(e))
+ self.assertEqual(
+ "Cannot specify option --disable-reason without "
+ "--disable specified.",
+ str(e),
+ )
diff --git a/openstackclient/tests/unit/volume/v2/test_type.py b/openstackclient/tests/unit/volume/v2/test_type.py
index 1cb46c45..b387f54c 100644
--- a/openstackclient/tests/unit/volume/v2/test_type.py
+++ b/openstackclient/tests/unit/volume/v2/test_type.py
@@ -26,7 +26,6 @@ from openstackclient.volume.v2 import volume_type
class TestType(volume_fakes.TestVolume):
-
def setUp(self):
super().setUp()
@@ -34,11 +33,13 @@ class TestType(volume_fakes.TestVolume):
self.types_mock.reset_mock()
self.types_access_mock = (
- self.app.client_manager.volume.volume_type_access)
+ self.app.client_manager.volume.volume_type_access
+ )
self.types_access_mock.reset_mock()
self.encryption_types_mock = (
- self.app.client_manager.volume.volume_encryption_types)
+ self.app.client_manager.volume.volume_encryption_types
+ )
self.encryption_types_mock.reset_mock()
self.projects_mock = self.app.client_manager.identity.projects
@@ -46,7 +47,6 @@ class TestType(volume_fakes.TestVolume):
class TestTypeCreate(TestType):
-
project = identity_fakes.FakeProject.create_one_project()
columns = (
'description',
@@ -73,7 +73,8 @@ class TestTypeCreate(TestType):
def test_type_create_public(self):
arglist = [
- "--description", self.new_volume_type.description,
+ "--description",
+ self.new_volume_type.description,
"--public",
self.new_volume_type.name,
]
@@ -97,9 +98,11 @@ class TestTypeCreate(TestType):
def test_type_create_private(self):
arglist = [
- "--description", self.new_volume_type.description,
+ "--description",
+ self.new_volume_type.description,
"--private",
- "--project", self.project.id,
+ "--project",
+ self.project.id,
self.new_volume_type.name,
]
verifylist = [
@@ -123,7 +126,8 @@ class TestTypeCreate(TestType):
def test_public_type_create_with_project(self):
arglist = [
- '--project', self.project.id,
+ '--project',
+ self.project.id,
self.new_volume_type.name,
]
verifylist = [
@@ -132,9 +136,9 @@ class TestTypeCreate(TestType):
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
- self.assertRaises(exceptions.CommandError,
- self.cmd.take_action,
- parsed_args)
+ self.assertRaises(
+ exceptions.CommandError, self.cmd.take_action, parsed_args
+ )
def test_type_create_with_encryption(self):
encryption_info = {
@@ -166,10 +170,14 @@ class TestTypeCreate(TestType):
self.new_volume_type.name,
)
arglist = [
- '--encryption-provider', 'LuksEncryptor',
- '--encryption-cipher', 'aes-xts-plain64',
- '--encryption-key-size', '128',
- '--encryption-control-location', 'front-end',
+ '--encryption-provider',
+ 'LuksEncryptor',
+ '--encryption-cipher',
+ 'aes-xts-plain64',
+ '--encryption-key-size',
+ '128',
+ '--encryption-control-location',
+ 'front-end',
self.new_volume_type.name,
]
verifylist = [
@@ -201,7 +209,6 @@ class TestTypeCreate(TestType):
class TestTypeDelete(TestType):
-
volume_types = volume_fakes.create_volume_types(count=2)
def setUp(self):
@@ -216,12 +223,8 @@ class TestTypeDelete(TestType):
self.cmd = volume_type.DeleteVolumeType(self.app, None)
def test_type_delete(self):
- arglist = [
- self.volume_types[0].id
- ]
- verifylist = [
- ("volume_types", [self.volume_types[0].id])
- ]
+ arglist = [self.volume_types[0].id]
+ verifylist = [("volume_types", [self.volume_types[0].id])]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
result = self.cmd.take_action(parsed_args)
@@ -258,16 +261,17 @@ class TestTypeDelete(TestType):
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
find_mock_result = [self.volume_types[0], exceptions.CommandError]
- with mock.patch.object(utils, 'find_resource',
- side_effect=find_mock_result) as find_mock:
+ with mock.patch.object(
+ utils, 'find_resource', side_effect=find_mock_result
+ ) as find_mock:
try:
self.cmd.take_action(parsed_args)
self.fail('CommandError should be raised.')
except exceptions.CommandError as e:
- self.assertEqual('1 of 2 volume types failed to delete.',
- str(e))
- find_mock.assert_any_call(
- self.types_mock, self.volume_types[0].id)
+ self.assertEqual(
+ '1 of 2 volume types failed to delete.', str(e)
+ )
+ find_mock.assert_any_call(self.types_mock, self.volume_types[0].id)
find_mock.assert_any_call(self.types_mock, 'unexist_type')
self.assertEqual(2, find_mock.call_count)
@@ -277,7 +281,6 @@ class TestTypeDelete(TestType):
class TestTypeList(TestType):
-
volume_types = volume_fakes.create_volume_types()
columns = [
@@ -285,31 +288,28 @@ class TestTypeList(TestType):
"Name",
"Is Public",
]
- columns_long = columns + [
- "Description",
- "Properties"
- ]
- data_with_default_type = [(
- volume_types[0].id,
- volume_types[0].name,
- True
- )]
+ columns_long = columns + ["Description", "Properties"]
+ data_with_default_type = [(volume_types[0].id, volume_types[0].name, True)]
data = []
for t in volume_types:
- data.append((
- t.id,
- t.name,
- t.is_public,
- ))
+ data.append(
+ (
+ t.id,
+ t.name,
+ t.is_public,
+ )
+ )
data_long = []
for t in volume_types:
- data_long.append((
- t.id,
- t.name,
- t.is_public,
- t.description,
- format_columns.DictColumn(t.extra_specs),
- ))
+ data_long.append(
+ (
+ t.id,
+ t.name,
+ t.is_public,
+ t.description,
+ format_columns.DictColumn(t.extra_specs),
+ )
+ )
def setUp(self):
super().setUp()
@@ -401,21 +401,25 @@ class TestTypeList(TestType):
"Encryption",
]
encryption_data = []
- encryption_data.append((
- self.volume_types[0].id,
- self.volume_types[0].name,
- self.volume_types[0].is_public,
- volume_type.EncryptionInfoColumn(
+ encryption_data.append(
+ (
self.volume_types[0].id,
- {self.volume_types[0].id: encryption_info}),
- ))
- encryption_data.append((
- self.volume_types[1].id,
- self.volume_types[1].name,
- self.volume_types[1].is_public,
- volume_type.EncryptionInfoColumn(
- self.volume_types[1].id, {}),
- ))
+ self.volume_types[0].name,
+ self.volume_types[0].is_public,
+ volume_type.EncryptionInfoColumn(
+ self.volume_types[0].id,
+ {self.volume_types[0].id: encryption_info},
+ ),
+ )
+ )
+ encryption_data.append(
+ (
+ self.volume_types[1].id,
+ self.volume_types[1].name,
+ self.volume_types[1].is_public,
+ volume_type.EncryptionInfoColumn(self.volume_types[1].id, {}),
+ )
+ )
self.encryption_types_mock.list.return_value = [encryption_type]
arglist = [
@@ -434,7 +438,6 @@ class TestTypeList(TestType):
class TestTypeSet(TestType):
-
project = identity_fakes.FakeProject.create_one_project()
volume_type = volume_fakes.create_one_volume_type(
methods={'set_keys': None},
@@ -455,7 +458,8 @@ class TestTypeSet(TestType):
def test_type_set_name(self):
new_name = 'new_name'
arglist = [
- '--name', new_name,
+ '--name',
+ new_name,
self.volume_type.id,
]
verifylist = [
@@ -473,15 +477,15 @@ class TestTypeSet(TestType):
'name': new_name,
}
self.types_mock.update.assert_called_with(
- self.volume_type.id,
- **kwargs
+ self.volume_type.id, **kwargs
)
self.assertIsNone(result)
def test_type_set_description(self):
new_desc = 'new_desc'
arglist = [
- '--description', new_desc,
+ '--description',
+ new_desc,
self.volume_type.id,
]
verifylist = [
@@ -499,14 +503,14 @@ class TestTypeSet(TestType):
'description': new_desc,
}
self.types_mock.update.assert_called_with(
- self.volume_type.id,
- **kwargs
+ self.volume_type.id, **kwargs
)
self.assertIsNone(result)
def test_type_set_property(self):
arglist = [
- '--property', 'myprop=myvalue',
+ '--property',
+ 'myprop=myvalue',
self.volume_type.id,
]
verifylist = [
@@ -519,12 +523,14 @@ class TestTypeSet(TestType):
result = self.cmd.take_action(parsed_args)
self.volume_type.set_keys.assert_called_once_with(
- {'myprop': 'myvalue'})
+ {'myprop': 'myvalue'}
+ )
self.assertIsNone(result)
def test_type_set_not_called_without_project_argument(self):
arglist = [
- '--project', '',
+ '--project',
+ '',
self.volume_type.id,
]
verifylist = [
@@ -541,21 +547,25 @@ class TestTypeSet(TestType):
def test_type_set_failed_with_missing_volume_type_argument(self):
arglist = [
- '--project', 'identity_fakes.project_id',
+ '--project',
+ 'identity_fakes.project_id',
]
verifylist = [
('project', 'identity_fakes.project_id'),
]
- self.assertRaises(tests_utils.ParserException,
- self.check_parser,
- self.cmd,
- arglist,
- verifylist)
+ self.assertRaises(
+ tests_utils.ParserException,
+ self.check_parser,
+ self.cmd,
+ arglist,
+ verifylist,
+ )
def test_type_set_project_access(self):
arglist = [
- '--project', self.project.id,
+ '--project',
+ self.project.id,
self.volume_type.id,
]
verifylist = [
@@ -573,13 +583,18 @@ class TestTypeSet(TestType):
)
def test_type_set_new_encryption(self):
- self.encryption_types_mock.update.side_effect = (
- exceptions.NotFound('NotFound'))
+ self.encryption_types_mock.update.side_effect = exceptions.NotFound(
+ 'NotFound'
+ )
arglist = [
- '--encryption-provider', 'LuksEncryptor',
- '--encryption-cipher', 'aes-xts-plain64',
- '--encryption-key-size', '128',
- '--encryption-control-location', 'front-end',
+ '--encryption-provider',
+ 'LuksEncryptor',
+ '--encryption-cipher',
+ 'aes-xts-plain64',
+ '--encryption-key-size',
+ '128',
+ '--encryption-control-location',
+ 'front-end',
self.volume_type.id,
]
verifylist = [
@@ -610,12 +625,14 @@ class TestTypeSet(TestType):
@mock.patch.object(utils, 'find_resource')
def test_type_set_existing_encryption(self, mock_find):
- mock_find.side_effect = [self.volume_type,
- "existing_encryption_type"]
+ mock_find.side_effect = [self.volume_type, "existing_encryption_type"]
arglist = [
- '--encryption-provider', 'LuksEncryptor',
- '--encryption-cipher', 'aes-xts-plain64',
- '--encryption-control-location', 'front-end',
+ '--encryption-provider',
+ 'LuksEncryptor',
+ '--encryption-cipher',
+ 'aes-xts-plain64',
+ '--encryption-control-location',
+ 'front-end',
self.volume_type.id,
]
verifylist = [
@@ -640,12 +657,16 @@ class TestTypeSet(TestType):
self.assertIsNone(result)
def test_type_set_new_encryption_without_provider(self):
- self.encryption_types_mock.update.side_effect = (
- exceptions.NotFound('NotFound'))
+ self.encryption_types_mock.update.side_effect = exceptions.NotFound(
+ 'NotFound'
+ )
arglist = [
- '--encryption-cipher', 'aes-xts-plain64',
- '--encryption-key-size', '128',
- '--encryption-control-location', 'front-end',
+ '--encryption-cipher',
+ 'aes-xts-plain64',
+ '--encryption-key-size',
+ '128',
+ '--encryption-control-location',
+ 'front-end',
self.volume_type.id,
]
verifylist = [
@@ -659,9 +680,10 @@ class TestTypeSet(TestType):
self.cmd.take_action(parsed_args)
self.fail('CommandError should be raised.')
except exceptions.CommandError as e:
- self.assertEqual("Command Failed: One or more of"
- " the operations failed",
- str(e))
+ self.assertEqual(
+ "Command Failed: One or more of" " the operations failed",
+ str(e),
+ )
body = {
'cipher': 'aes-xts-plain64',
'key_size': 128,
@@ -675,7 +697,6 @@ class TestTypeSet(TestType):
class TestTypeShow(TestType):
-
columns = (
'access_project_ids',
'description',
@@ -695,7 +716,7 @@ class TestTypeShow(TestType):
self.volume_type.id,
True,
self.volume_type.name,
- format_columns.DictColumn(self.volume_type.extra_specs)
+ format_columns.DictColumn(self.volume_type.extra_specs),
)
self.types_mock.get.return_value = self.volume_type
@@ -704,12 +725,10 @@ class TestTypeShow(TestType):
self.cmd = volume_type.ShowVolumeType(self.app, None)
def test_type_show(self):
- arglist = [
- self.volume_type.id
- ]
+ arglist = [self.volume_type.id]
verifylist = [
("encryption_type", False),
- ("volume_type", self.volume_type.id)
+ ("volume_type", self.volume_type.id),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -720,12 +739,8 @@ class TestTypeShow(TestType):
self.assertCountEqual(self.data, data)
def test_type_show_with_access(self):
- arglist = [
- self.volume_type.id
- ]
- verifylist = [
- ("volume_type", self.volume_type.id)
- ]
+ arglist = [self.volume_type.id]
+ verifylist = [("volume_type", self.volume_type.id)]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
private_type = volume_fakes.create_one_volume_type(
@@ -744,9 +759,11 @@ class TestTypeShow(TestType):
):
columns, data = self.cmd.take_action(parsed_args)
self.types_mock.get.assert_called_once_with(
- self.volume_type.id)
+ self.volume_type.id
+ )
self.types_access_mock.list.assert_called_once_with(
- private_type.id)
+ private_type.id
+ )
self.assertEqual(self.columns, columns)
private_type_data = (
@@ -755,31 +772,31 @@ class TestTypeShow(TestType):
private_type.id,
private_type.is_public,
private_type.name,
- format_columns.DictColumn(private_type.extra_specs)
+ format_columns.DictColumn(private_type.extra_specs),
)
self.assertCountEqual(private_type_data, data)
def test_type_show_with_list_access_exec(self):
- arglist = [
- self.volume_type.id
- ]
- verifylist = [
- ("volume_type", self.volume_type.id)
- ]
+ arglist = [self.volume_type.id]
+ verifylist = [("volume_type", self.volume_type.id)]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
private_type = volume_fakes.create_one_volume_type(
attrs={'is_public': False},
)
- with mock.patch.object(self.types_mock, 'get',
- return_value=private_type):
- with mock.patch.object(self.types_access_mock, 'list',
- side_effect=Exception()):
+ with mock.patch.object(
+ self.types_mock, 'get', return_value=private_type
+ ):
+ with mock.patch.object(
+ self.types_access_mock, 'list', side_effect=Exception()
+ ):
columns, data = self.cmd.take_action(parsed_args)
self.types_mock.get.assert_called_once_with(
- self.volume_type.id)
+ self.volume_type.id
+ )
self.types_access_mock.list.assert_called_once_with(
- private_type.id)
+ private_type.id
+ )
self.assertEqual(self.columns, columns)
private_type_data = (
@@ -788,7 +805,7 @@ class TestTypeShow(TestType):
private_type.id,
private_type.is_public,
private_type.name,
- format_columns.DictColumn(private_type.extra_specs)
+ format_columns.DictColumn(private_type.extra_specs),
)
self.assertCountEqual(private_type_data, data)
@@ -821,15 +838,12 @@ class TestTypeShow(TestType):
self.volume_type.id,
True,
self.volume_type.name,
- format_columns.DictColumn(self.volume_type.extra_specs)
+ format_columns.DictColumn(self.volume_type.extra_specs),
)
- arglist = [
- '--encryption-type',
- self.volume_type.id
- ]
+ arglist = ['--encryption-type', self.volume_type.id]
verifylist = [
('encryption_type', True),
- ("volume_type", self.volume_type.id)
+ ("volume_type", self.volume_type.id),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -841,7 +855,6 @@ class TestTypeShow(TestType):
class TestTypeUnset(TestType):
-
project = identity_fakes.FakeProject.create_one_project()
volume_type = volume_fakes.create_one_volume_type(
methods={'unset_keys': None},
@@ -860,8 +873,10 @@ class TestTypeUnset(TestType):
def test_type_unset(self):
arglist = [
- '--property', 'property',
- '--property', 'multi_property',
+ '--property',
+ 'property',
+ '--property',
+ 'multi_property',
self.volume_type.id,
]
verifylist = [
@@ -873,12 +888,14 @@ class TestTypeUnset(TestType):
result = self.cmd.take_action(parsed_args)
self.volume_type.unset_keys.assert_called_once_with(
- ['property', 'multi_property'])
+ ['property', 'multi_property']
+ )
self.assertIsNone(result)
def test_type_unset_project_access(self):
arglist = [
- '--project', self.project.id,
+ '--project',
+ self.project.id,
self.volume_type.id,
]
verifylist = [
@@ -897,7 +914,8 @@ class TestTypeUnset(TestType):
def test_type_unset_not_called_without_project_argument(self):
arglist = [
- '--project', '',
+ '--project',
+ '',
self.volume_type.id,
]
verifylist = [
@@ -915,17 +933,20 @@ class TestTypeUnset(TestType):
def test_type_unset_failed_with_missing_volume_type_argument(self):
arglist = [
- '--project', 'identity_fakes.project_id',
+ '--project',
+ 'identity_fakes.project_id',
]
verifylist = [
('project', 'identity_fakes.project_id'),
]
- self.assertRaises(tests_utils.ParserException,
- self.check_parser,
- self.cmd,
- arglist,
- verifylist)
+ self.assertRaises(
+ tests_utils.ParserException,
+ self.check_parser,
+ self.cmd,
+ arglist,
+ verifylist,
+ )
def test_type_unset_encryption_type(self):
arglist = [
@@ -944,7 +965,6 @@ class TestTypeUnset(TestType):
class TestColumns(TestType):
-
def test_encryption_info_column_with_info(self):
fake_volume_type = volume_fakes.create_one_volume_type()
type_id = fake_volume_type.id
@@ -955,10 +975,12 @@ class TestColumns(TestType):
'key_size': None,
'control_location': 'front-end',
}
- col = volume_type.EncryptionInfoColumn(type_id,
- {type_id: encryption_info})
- self.assertEqual(utils.format_dict(encryption_info),
- col.human_readable())
+ col = volume_type.EncryptionInfoColumn(
+ type_id, {type_id: encryption_info}
+ )
+ self.assertEqual(
+ utils.format_dict(encryption_info), col.human_readable()
+ )
self.assertEqual(encryption_info, col.machine_readable())
def test_encryption_info_column_without_info(self):
diff --git a/openstackclient/tests/unit/volume/v2/test_volume.py b/openstackclient/tests/unit/volume/v2/test_volume.py
index 0419acef..8a743725 100644
--- a/openstackclient/tests/unit/volume/v2/test_volume.py
+++ b/openstackclient/tests/unit/volume/v2/test_volume.py
@@ -29,7 +29,6 @@ from openstackclient.volume.v2 import volume
class TestVolume(volume_fakes.TestVolume):
-
def setUp(self):
super().setUp()
@@ -55,7 +54,8 @@ class TestVolume(volume_fakes.TestVolume):
self.types_mock.reset_mock()
self.consistencygroups_mock = (
- self.app.client_manager.volume.consistencygroups)
+ self.app.client_manager.volume.consistencygroups
+ )
self.consistencygroups_mock.reset_mock()
def setup_volumes_mock(self, count):
@@ -66,7 +66,6 @@ class TestVolume(volume_fakes.TestVolume):
class TestVolumeCreate(TestVolume):
-
project = identity_fakes.FakeProject.create_one_project()
user = identity_fakes.FakeUser.create_one_user()
@@ -109,7 +108,8 @@ class TestVolumeCreate(TestVolume):
def test_volume_create_min_options(self):
arglist = [
- '--size', str(self.new_volume.size),
+ '--size',
+ str(self.new_volume.size),
]
verifylist = [
('size', self.new_volume.size),
@@ -143,12 +143,18 @@ class TestVolumeCreate(TestVolume):
consistency_group = volume_fakes.create_one_consistency_group()
self.consistencygroups_mock.get.return_value = consistency_group
arglist = [
- '--size', str(self.new_volume.size),
- '--description', self.new_volume.description,
- '--type', self.new_volume.volume_type,
- '--availability-zone', self.new_volume.availability_zone,
- '--consistency-group', consistency_group.id,
- '--hint', 'k=v',
+ '--size',
+ str(self.new_volume.size),
+ '--description',
+ self.new_volume.description,
+ '--type',
+ self.new_volume.volume_type,
+ '--availability-zone',
+ self.new_volume.availability_zone,
+ '--consistency-group',
+ consistency_group.id,
+ '--hint',
+ 'k=v',
self.new_volume.name,
]
verifylist = [
@@ -187,9 +193,12 @@ class TestVolumeCreate(TestVolume):
def test_volume_create_properties(self):
arglist = [
- '--property', 'Alpha=a',
- '--property', 'Beta=b',
- '--size', str(self.new_volume.size),
+ '--property',
+ 'Alpha=a',
+ '--property',
+ 'Beta=b',
+ '--size',
+ str(self.new_volume.size),
self.new_volume.name,
]
verifylist = [
@@ -227,8 +236,10 @@ class TestVolumeCreate(TestVolume):
self.find_image_mock.return_value = image
arglist = [
- '--image', image.id,
- '--size', str(self.new_volume.size),
+ '--image',
+ image.id,
+ '--size',
+ str(self.new_volume.size),
self.new_volume.name,
]
verifylist = [
@@ -266,8 +277,10 @@ class TestVolumeCreate(TestVolume):
self.find_image_mock.return_value = image
arglist = [
- '--image', image.name,
- '--size', str(self.new_volume.size),
+ '--image',
+ image.name,
+ '--size',
+ str(self.new_volume.size),
self.new_volume.name,
]
verifylist = [
@@ -304,7 +317,8 @@ class TestVolumeCreate(TestVolume):
snapshot = volume_fakes.create_one_snapshot()
self.new_volume.snapshot_id = snapshot.id
arglist = [
- '--snapshot', self.new_volume.snapshot_id,
+ '--snapshot',
+ self.new_volume.snapshot_id,
self.new_volume.name,
]
verifylist = [
@@ -342,7 +356,8 @@ class TestVolumeCreate(TestVolume):
backup = volume_fakes.create_one_backup()
self.new_volume.backup_id = backup.id
arglist = [
- '--backup', self.new_volume.backup_id,
+ '--backup',
+ self.new_volume.backup_id,
self.new_volume.name,
]
verifylist = [
@@ -353,8 +368,9 @@ class TestVolumeCreate(TestVolume):
self.backups_mock.get.return_value = backup
- self.app.client_manager.volume.api_version = \
- api_versions.APIVersion('3.47')
+ self.app.client_manager.volume.api_version = api_versions.APIVersion(
+ '3.47'
+ )
# In base command class ShowOne in cliff, abstract method take_action()
# returns a two-part tuple with a tuple of column names and a tuple of
@@ -383,7 +399,8 @@ class TestVolumeCreate(TestVolume):
backup = volume_fakes.create_one_backup()
self.new_volume.backup_id = backup.id
arglist = [
- '--backup', self.new_volume.backup_id,
+ '--backup',
+ self.new_volume.backup_id,
self.new_volume.name,
]
verifylist = [
@@ -394,14 +411,16 @@ class TestVolumeCreate(TestVolume):
self.backups_mock.get.return_value = backup
- exc = self.assertRaises(exceptions.CommandError, self.cmd.take_action,
- parsed_args)
+ exc = self.assertRaises(
+ exceptions.CommandError, self.cmd.take_action, parsed_args
+ )
self.assertIn("--os-volume-api-version 3.47 or greater", str(exc))
def test_volume_create_with_source_volume(self):
source_vol = "source_vol"
arglist = [
- '--source', self.new_volume.id,
+ '--source',
+ self.new_volume.id,
source_vol,
]
verifylist = [
@@ -440,7 +459,8 @@ class TestVolumeCreate(TestVolume):
arglist = [
'--bootable',
'--read-only',
- '--size', str(self.new_volume.size),
+ '--size',
+ str(self.new_volume.size),
self.new_volume.name,
]
verifylist = [
@@ -452,8 +472,7 @@ class TestVolumeCreate(TestVolume):
('name', self.new_volume.name),
]
- parsed_args = self.check_parser(
- self.cmd, arglist, verifylist)
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
columns, data = self.cmd.take_action(parsed_args)
@@ -475,16 +494,19 @@ class TestVolumeCreate(TestVolume):
self.assertEqual(self.columns, columns)
self.assertCountEqual(self.datalist, data)
self.volumes_mock.set_bootable.assert_called_with(
- self.new_volume.id, True)
+ self.new_volume.id, True
+ )
self.volumes_mock.update_readonly_flag.assert_called_with(
- self.new_volume.id, True)
+ self.new_volume.id, True
+ )
@mock.patch.object(utils, 'wait_for_status', return_value=True)
def test_volume_create_with_nonbootable_and_readwrite(self, mock_wait):
arglist = [
'--non-bootable',
'--read-write',
- '--size', str(self.new_volume.size),
+ '--size',
+ str(self.new_volume.size),
self.new_volume.name,
]
verifylist = [
@@ -496,8 +518,7 @@ class TestVolumeCreate(TestVolume):
('name', self.new_volume.name),
]
- parsed_args = self.check_parser(
- self.cmd, arglist, verifylist)
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
columns, data = self.cmd.take_action(parsed_args)
@@ -519,25 +540,28 @@ class TestVolumeCreate(TestVolume):
self.assertEqual(self.columns, columns)
self.assertCountEqual(self.datalist, data)
self.volumes_mock.set_bootable.assert_called_with(
- self.new_volume.id, False)
+ self.new_volume.id, False
+ )
self.volumes_mock.update_readonly_flag.assert_called_with(
- self.new_volume.id, False)
+ self.new_volume.id, False
+ )
@mock.patch.object(volume.LOG, 'error')
@mock.patch.object(utils, 'wait_for_status', return_value=True)
def test_volume_create_with_bootable_and_readonly_fail(
- self, mock_wait, mock_error):
-
- self.volumes_mock.set_bootable.side_effect = (
- exceptions.CommandError())
+ self, mock_wait, mock_error
+ ):
+ self.volumes_mock.set_bootable.side_effect = exceptions.CommandError()
self.volumes_mock.update_readonly_flag.side_effect = (
- exceptions.CommandError())
+ exceptions.CommandError()
+ )
arglist = [
'--bootable',
'--read-only',
- '--size', str(self.new_volume.size),
+ '--size',
+ str(self.new_volume.size),
self.new_volume.name,
]
verifylist = [
@@ -549,8 +573,7 @@ class TestVolumeCreate(TestVolume):
('name', self.new_volume.name),
]
- parsed_args = self.check_parser(
- self.cmd, arglist, verifylist)
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
columns, data = self.cmd.take_action(parsed_args)
@@ -573,19 +596,24 @@ class TestVolumeCreate(TestVolume):
self.assertEqual(self.columns, columns)
self.assertCountEqual(self.datalist, data)
self.volumes_mock.set_bootable.assert_called_with(
- self.new_volume.id, True)
+ self.new_volume.id, True
+ )
self.volumes_mock.update_readonly_flag.assert_called_with(
- self.new_volume.id, True)
+ self.new_volume.id, True
+ )
@mock.patch.object(volume.LOG, 'error')
@mock.patch.object(utils, 'wait_for_status', return_value=False)
def test_volume_create_non_available_with_readonly(
- self, mock_wait, mock_error,
+ self,
+ mock_wait,
+ mock_error,
):
arglist = [
'--non-bootable',
'--read-only',
- '--size', str(self.new_volume.size),
+ '--size',
+ str(self.new_volume.size),
self.new_volume.name,
]
verifylist = [
@@ -597,8 +625,7 @@ class TestVolumeCreate(TestVolume):
('name', self.new_volume.name),
]
- parsed_args = self.check_parser(
- self.cmd, arglist, verifylist)
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
columns, data = self.cmd.take_action(parsed_args)
@@ -630,15 +657,20 @@ class TestVolumeCreate(TestVolume):
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
- self.assertRaises(exceptions.CommandError, self.cmd.take_action,
- parsed_args)
+ self.assertRaises(
+ exceptions.CommandError, self.cmd.take_action, parsed_args
+ )
def test_volume_create_with_multi_source(self):
arglist = [
- '--image', 'source_image',
- '--source', 'source_volume',
- '--snapshot', 'source_snapshot',
- '--size', str(self.new_volume.size),
+ '--image',
+ 'source_image',
+ '--source',
+ 'source_volume',
+ '--snapshot',
+ 'source_snapshot',
+ '--size',
+ str(self.new_volume.size),
self.new_volume.name,
]
verifylist = [
@@ -649,12 +681,16 @@ class TestVolumeCreate(TestVolume):
('name', self.new_volume.name),
]
- self.assertRaises(tests_utils.ParserException, self.check_parser,
- self.cmd, arglist, verifylist)
+ self.assertRaises(
+ tests_utils.ParserException,
+ self.check_parser,
+ self.cmd,
+ arglist,
+ verifylist,
+ )
class TestVolumeDelete(TestVolume):
-
def setUp(self):
super().setUp()
@@ -666,9 +702,7 @@ class TestVolumeDelete(TestVolume):
def test_volume_delete_one_volume(self):
volumes = self.setup_volumes_mock(count=1)
- arglist = [
- volumes[0].id
- ]
+ arglist = [volumes[0].id]
verifylist = [
("force", False),
("purge", False),
@@ -679,7 +713,8 @@ class TestVolumeDelete(TestVolume):
result = self.cmd.take_action(parsed_args)
self.volumes_mock.delete.assert_called_once_with(
- volumes[0].id, cascade=False)
+ volumes[0].id, cascade=False
+ )
self.assertIsNone(result)
def test_volume_delete_multi_volumes(self):
@@ -714,21 +749,22 @@ class TestVolumeDelete(TestVolume):
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
find_mock_result = [volumes[0], exceptions.CommandError]
- with mock.patch.object(utils, 'find_resource',
- side_effect=find_mock_result) as find_mock:
+ with mock.patch.object(
+ utils, 'find_resource', side_effect=find_mock_result
+ ) as find_mock:
try:
self.cmd.take_action(parsed_args)
self.fail('CommandError should be raised.')
except exceptions.CommandError as e:
- self.assertEqual('1 of 2 volumes failed to delete.',
- str(e))
+ self.assertEqual('1 of 2 volumes failed to delete.', str(e))
find_mock.assert_any_call(self.volumes_mock, volumes[0].id)
find_mock.assert_any_call(self.volumes_mock, 'unexist_volume')
self.assertEqual(2, find_mock.call_count)
self.volumes_mock.delete.assert_called_once_with(
- volumes[0].id, cascade=False)
+ volumes[0].id, cascade=False
+ )
def test_volume_delete_with_purge(self):
volumes = self.setup_volumes_mock(count=1)
@@ -747,7 +783,8 @@ class TestVolumeDelete(TestVolume):
result = self.cmd.take_action(parsed_args)
self.volumes_mock.delete.assert_called_once_with(
- volumes[0].id, cascade=True)
+ volumes[0].id, cascade=True
+ )
self.assertIsNone(result)
def test_volume_delete_with_force(self):
@@ -771,7 +808,6 @@ class TestVolumeDelete(TestVolume):
class TestVolumeList(TestVolume):
-
project = identity_fakes.FakeProject.create_one_project()
user = identity_fakes.FakeUser.create_one_user()
@@ -825,18 +861,21 @@ class TestVolumeList(TestVolume):
self.assertEqual(self.columns, columns)
- datalist = ((
- self.mock_volume.id,
- self.mock_volume.name,
- self.mock_volume.status,
- self.mock_volume.size,
- volume.AttachmentsColumn(self.mock_volume.attachments),
- ), )
+ datalist = (
+ (
+ self.mock_volume.id,
+ self.mock_volume.name,
+ self.mock_volume.status,
+ self.mock_volume.size,
+ volume.AttachmentsColumn(self.mock_volume.attachments),
+ ),
+ )
self.assertCountEqual(datalist, tuple(data))
def test_volume_list_project(self):
arglist = [
- '--project', self.project.name,
+ '--project',
+ self.project.name,
]
verifylist = [
('project', self.project.name),
@@ -865,19 +904,23 @@ class TestVolumeList(TestVolume):
self.assertEqual(self.columns, columns)
- datalist = ((
- self.mock_volume.id,
- self.mock_volume.name,
- self.mock_volume.status,
- self.mock_volume.size,
- volume.AttachmentsColumn(self.mock_volume.attachments),
- ), )
+ datalist = (
+ (
+ self.mock_volume.id,
+ self.mock_volume.name,
+ self.mock_volume.status,
+ self.mock_volume.size,
+ volume.AttachmentsColumn(self.mock_volume.attachments),
+ ),
+ )
self.assertCountEqual(datalist, tuple(data))
def test_volume_list_project_domain(self):
arglist = [
- '--project', self.project.name,
- '--project-domain', self.project.domain_id,
+ '--project',
+ self.project.name,
+ '--project-domain',
+ self.project.domain_id,
]
verifylist = [
('project', self.project.name),
@@ -907,18 +950,21 @@ class TestVolumeList(TestVolume):
self.assertEqual(self.columns, columns)
- datalist = ((
- self.mock_volume.id,
- self.mock_volume.name,
- self.mock_volume.status,
- self.mock_volume.size,
- volume.AttachmentsColumn(self.mock_volume.attachments),
- ), )
+ datalist = (
+ (
+ self.mock_volume.id,
+ self.mock_volume.name,
+ self.mock_volume.status,
+ self.mock_volume.size,
+ volume.AttachmentsColumn(self.mock_volume.attachments),
+ ),
+ )
self.assertCountEqual(datalist, tuple(data))
def test_volume_list_user(self):
arglist = [
- '--user', self.user.name,
+ '--user',
+ self.user.name,
]
verifylist = [
('user', self.user.name),
@@ -946,19 +992,23 @@ class TestVolumeList(TestVolume):
)
self.assertEqual(self.columns, columns)
- datalist = ((
- self.mock_volume.id,
- self.mock_volume.name,
- self.mock_volume.status,
- self.mock_volume.size,
- volume.AttachmentsColumn(self.mock_volume.attachments),
- ), )
+ datalist = (
+ (
+ self.mock_volume.id,
+ self.mock_volume.name,
+ self.mock_volume.status,
+ self.mock_volume.size,
+ volume.AttachmentsColumn(self.mock_volume.attachments),
+ ),
+ )
self.assertCountEqual(datalist, tuple(data))
def test_volume_list_user_domain(self):
arglist = [
- '--user', self.user.name,
- '--user-domain', self.user.domain_id,
+ '--user',
+ self.user.name,
+ '--user-domain',
+ self.user.domain_id,
]
verifylist = [
('user', self.user.name),
@@ -988,18 +1038,21 @@ class TestVolumeList(TestVolume):
self.assertEqual(self.columns, columns)
- datalist = ((
- self.mock_volume.id,
- self.mock_volume.name,
- self.mock_volume.status,
- self.mock_volume.size,
- volume.AttachmentsColumn(self.mock_volume.attachments),
- ), )
+ datalist = (
+ (
+ self.mock_volume.id,
+ self.mock_volume.name,
+ self.mock_volume.status,
+ self.mock_volume.size,
+ volume.AttachmentsColumn(self.mock_volume.attachments),
+ ),
+ )
self.assertCountEqual(datalist, tuple(data))
def test_volume_list_name(self):
arglist = [
- '--name', self.mock_volume.name,
+ '--name',
+ self.mock_volume.name,
]
verifylist = [
('long', False),
@@ -1028,18 +1081,21 @@ class TestVolumeList(TestVolume):
self.assertEqual(self.columns, columns)
- datalist = ((
- self.mock_volume.id,
- self.mock_volume.name,
- self.mock_volume.status,
- self.mock_volume.size,
- volume.AttachmentsColumn(self.mock_volume.attachments),
- ), )
+ datalist = (
+ (
+ self.mock_volume.id,
+ self.mock_volume.name,
+ self.mock_volume.status,
+ self.mock_volume.size,
+ volume.AttachmentsColumn(self.mock_volume.attachments),
+ ),
+ )
self.assertCountEqual(datalist, tuple(data))
def test_volume_list_status(self):
arglist = [
- '--status', self.mock_volume.status,
+ '--status',
+ self.mock_volume.status,
]
verifylist = [
('long', False),
@@ -1068,13 +1124,15 @@ class TestVolumeList(TestVolume):
self.assertEqual(self.columns, columns)
- datalist = ((
- self.mock_volume.id,
- self.mock_volume.name,
- self.mock_volume.status,
- self.mock_volume.size,
- volume.AttachmentsColumn(self.mock_volume.attachments),
- ), )
+ datalist = (
+ (
+ self.mock_volume.id,
+ self.mock_volume.name,
+ self.mock_volume.status,
+ self.mock_volume.size,
+ volume.AttachmentsColumn(self.mock_volume.attachments),
+ ),
+ )
self.assertCountEqual(datalist, tuple(data))
def test_volume_list_all_projects(self):
@@ -1108,13 +1166,15 @@ class TestVolumeList(TestVolume):
self.assertEqual(self.columns, columns)
- datalist = ((
- self.mock_volume.id,
- self.mock_volume.name,
- self.mock_volume.status,
- self.mock_volume.size,
- volume.AttachmentsColumn(self.mock_volume.attachments),
- ), )
+ datalist = (
+ (
+ self.mock_volume.id,
+ self.mock_volume.name,
+ self.mock_volume.status,
+ self.mock_volume.size,
+ volume.AttachmentsColumn(self.mock_volume.attachments),
+ ),
+ )
self.assertCountEqual(datalist, tuple(data))
def test_volume_list_long(self):
@@ -1159,22 +1219,26 @@ class TestVolumeList(TestVolume):
]
self.assertEqual(collist, columns)
- datalist = ((
- self.mock_volume.id,
- self.mock_volume.name,
- self.mock_volume.status,
- self.mock_volume.size,
- self.mock_volume.volume_type,
- self.mock_volume.bootable,
- volume.AttachmentsColumn(self.mock_volume.attachments),
- format_columns.DictColumn(self.mock_volume.metadata),
- ), )
+ datalist = (
+ (
+ self.mock_volume.id,
+ self.mock_volume.name,
+ self.mock_volume.status,
+ self.mock_volume.size,
+ self.mock_volume.volume_type,
+ self.mock_volume.bootable,
+ volume.AttachmentsColumn(self.mock_volume.attachments),
+ format_columns.DictColumn(self.mock_volume.metadata),
+ ),
+ )
self.assertCountEqual(datalist, tuple(data))
def test_volume_list_with_marker_and_limit(self):
arglist = [
- "--marker", self.mock_volume.id,
- "--limit", "2",
+ "--marker",
+ self.mock_volume.id,
+ "--limit",
+ "2",
]
verifylist = [
('long', False),
@@ -1190,13 +1254,15 @@ class TestVolumeList(TestVolume):
self.assertEqual(self.columns, columns)
- datalist = ((
- self.mock_volume.id,
- self.mock_volume.name,
- self.mock_volume.status,
- self.mock_volume.size,
- volume.AttachmentsColumn(self.mock_volume.attachments),
- ), )
+ datalist = (
+ (
+ self.mock_volume.id,
+ self.mock_volume.name,
+ self.mock_volume.status,
+ self.mock_volume.size,
+ volume.AttachmentsColumn(self.mock_volume.attachments),
+ ),
+ )
self.volumes_mock.list.assert_called_once_with(
marker=self.mock_volume.id,
@@ -1206,23 +1272,31 @@ class TestVolumeList(TestVolume):
'project_id': None,
'user_id': None,
'name': None,
- 'all_tenants': False, }
+ 'all_tenants': False,
+ },
)
self.assertCountEqual(datalist, tuple(data))
def test_volume_list_negative_limit(self):
arglist = [
- "--limit", "-2",
+ "--limit",
+ "-2",
]
verifylist = [
("limit", -2),
]
- self.assertRaises(argparse.ArgumentTypeError, self.check_parser,
- self.cmd, arglist, verifylist)
+ self.assertRaises(
+ argparse.ArgumentTypeError,
+ self.check_parser,
+ self.cmd,
+ arglist,
+ verifylist,
+ )
def test_volume_list_backward_compatibility(self):
arglist = [
- '-c', 'Display Name',
+ '-c',
+ 'Display Name',
]
verifylist = [
('columns', ['Display Name']),
@@ -1258,7 +1332,6 @@ class TestVolumeList(TestVolume):
class TestVolumeMigrate(TestVolume):
-
_volume = volume_fakes.create_one_volume()
def setUp(self):
@@ -1271,7 +1344,8 @@ class TestVolumeMigrate(TestVolume):
def test_volume_migrate(self):
arglist = [
- "--host", "host@backend-name#pool",
+ "--host",
+ "host@backend-name#pool",
self._volume.id,
]
verifylist = [
@@ -1285,14 +1359,16 @@ class TestVolumeMigrate(TestVolume):
result = self.cmd.take_action(parsed_args)
self.volumes_mock.get.assert_called_once_with(self._volume.id)
self.volumes_mock.migrate_volume.assert_called_once_with(
- self._volume.id, "host@backend-name#pool", False, False)
+ self._volume.id, "host@backend-name#pool", False, False
+ )
self.assertIsNone(result)
def test_volume_migrate_with_option(self):
arglist = [
"--force-host-copy",
"--lock-volume",
- "--host", "host@backend-name#pool",
+ "--host",
+ "host@backend-name#pool",
self._volume.id,
]
verifylist = [
@@ -1306,7 +1382,8 @@ class TestVolumeMigrate(TestVolume):
result = self.cmd.take_action(parsed_args)
self.volumes_mock.get.assert_called_once_with(self._volume.id)
self.volumes_mock.migrate_volume.assert_called_once_with(
- self._volume.id, "host@backend-name#pool", True, True)
+ self._volume.id, "host@backend-name#pool", True, True
+ )
self.assertIsNone(result)
def test_volume_migrate_without_host(self):
@@ -1319,12 +1396,16 @@ class TestVolumeMigrate(TestVolume):
("volume", self._volume.id),
]
- self.assertRaises(tests_utils.ParserException, self.check_parser,
- self.cmd, arglist, verifylist)
+ self.assertRaises(
+ tests_utils.ParserException,
+ self.check_parser,
+ self.cmd,
+ arglist,
+ verifylist,
+ )
class TestVolumeSet(TestVolume):
-
volume_type = volume_fakes.create_one_volume_type()
def setUp(self):
@@ -1339,33 +1420,38 @@ class TestVolumeSet(TestVolume):
def test_volume_set_property(self):
arglist = [
- '--property', 'a=b',
- '--property', 'c=d',
+ '--property',
+ 'a=b',
+ '--property',
+ 'c=d',
self.new_volume.id,
]
verifylist = [
('property', {'a': 'b', 'c': 'd'}),
('volume', self.new_volume.id),
('bootable', False),
- ('non_bootable', False)
+ ('non_bootable', False),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
self.volumes_mock.set_metadata.assert_called_with(
- self.new_volume.id, parsed_args.property)
+ self.new_volume.id, parsed_args.property
+ )
def test_volume_set_image_property(self):
arglist = [
- '--image-property', 'Alpha=a',
- '--image-property', 'Beta=b',
+ '--image-property',
+ 'Alpha=a',
+ '--image-property',
+ 'Beta=b',
self.new_volume.id,
]
verifylist = [
('image_property', {'Alpha': 'a', 'Beta': 'b'}),
('volume', self.new_volume.id),
('bootable', False),
- ('non_bootable', False)
+ ('non_bootable', False),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -1373,211 +1459,192 @@ class TestVolumeSet(TestVolume):
# returns nothing
self.cmd.take_action(parsed_args)
self.volumes_mock.set_image_metadata.assert_called_with(
- self.new_volume.id, parsed_args.image_property)
+ self.new_volume.id, parsed_args.image_property
+ )
def test_volume_set_state(self):
- arglist = [
- '--state', 'error',
- self.new_volume.id
- ]
+ arglist = ['--state', 'error', self.new_volume.id]
verifylist = [
('read_only', False),
('read_write', False),
('state', 'error'),
- ('volume', self.new_volume.id)
+ ('volume', self.new_volume.id),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
result = self.cmd.take_action(parsed_args)
self.volumes_mock.reset_state.assert_called_with(
- self.new_volume.id, 'error')
+ self.new_volume.id, 'error'
+ )
self.volumes_mock.update_readonly_flag.assert_not_called()
self.assertIsNone(result)
def test_volume_set_state_failed(self):
self.volumes_mock.reset_state.side_effect = exceptions.CommandError()
- arglist = [
- '--state', 'error',
- self.new_volume.id
- ]
- verifylist = [
- ('state', 'error'),
- ('volume', self.new_volume.id)
- ]
+ arglist = ['--state', 'error', self.new_volume.id]
+ verifylist = [('state', 'error'), ('volume', self.new_volume.id)]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
try:
self.cmd.take_action(parsed_args)
self.fail('CommandError should be raised.')
except exceptions.CommandError as e:
- self.assertEqual('One or more of the set operations failed',
- str(e))
+ self.assertEqual(
+ 'One or more of the set operations failed', str(e)
+ )
self.volumes_mock.reset_state.assert_called_with(
- self.new_volume.id, 'error')
+ self.new_volume.id, 'error'
+ )
def test_volume_set_attached(self):
- arglist = [
- '--attached',
- self.new_volume.id
- ]
+ arglist = ['--attached', self.new_volume.id]
verifylist = [
('attached', True),
('detached', False),
- ('volume', self.new_volume.id)
+ ('volume', self.new_volume.id),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
result = self.cmd.take_action(parsed_args)
self.volumes_mock.reset_state.assert_called_with(
- self.new_volume.id, attach_status='attached', state=None)
+ self.new_volume.id, attach_status='attached', state=None
+ )
self.assertIsNone(result)
def test_volume_set_detached(self):
- arglist = [
- '--detached',
- self.new_volume.id
- ]
+ arglist = ['--detached', self.new_volume.id]
verifylist = [
('attached', False),
('detached', True),
- ('volume', self.new_volume.id)
+ ('volume', self.new_volume.id),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
result = self.cmd.take_action(parsed_args)
self.volumes_mock.reset_state.assert_called_with(
- self.new_volume.id, attach_status='detached', state=None)
+ self.new_volume.id, attach_status='detached', state=None
+ )
self.assertIsNone(result)
def test_volume_set_bootable(self):
arglist = [
['--bootable', self.new_volume.id],
- ['--non-bootable', self.new_volume.id]
+ ['--non-bootable', self.new_volume.id],
]
verifylist = [
[
('bootable', True),
('non_bootable', False),
- ('volume', self.new_volume.id)
+ ('volume', self.new_volume.id),
],
[
('bootable', False),
('non_bootable', True),
- ('volume', self.new_volume.id)
- ]
+ ('volume', self.new_volume.id),
+ ],
]
for index in range(len(arglist)):
parsed_args = self.check_parser(
- self.cmd, arglist[index], verifylist[index])
+ self.cmd, arglist[index], verifylist[index]
+ )
self.cmd.take_action(parsed_args)
self.volumes_mock.set_bootable.assert_called_with(
- self.new_volume.id, verifylist[index][0][1])
+ self.new_volume.id, verifylist[index][0][1]
+ )
def test_volume_set_readonly(self):
- arglist = [
- '--read-only',
- self.new_volume.id
- ]
+ arglist = ['--read-only', self.new_volume.id]
verifylist = [
('read_only', True),
('read_write', False),
- ('volume', self.new_volume.id)
+ ('volume', self.new_volume.id),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
result = self.cmd.take_action(parsed_args)
self.volumes_mock.update_readonly_flag.assert_called_once_with(
- self.new_volume.id,
- True)
+ self.new_volume.id, True
+ )
self.assertIsNone(result)
def test_volume_set_read_write(self):
- arglist = [
- '--read-write',
- self.new_volume.id
- ]
+ arglist = ['--read-write', self.new_volume.id]
verifylist = [
('read_only', False),
('read_write', True),
- ('volume', self.new_volume.id)
+ ('volume', self.new_volume.id),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
result = self.cmd.take_action(parsed_args)
self.volumes_mock.update_readonly_flag.assert_called_once_with(
- self.new_volume.id,
- False)
+ self.new_volume.id, False
+ )
self.assertIsNone(result)
def test_volume_set_type(self):
- arglist = [
- '--type', self.volume_type.id,
- self.new_volume.id
- ]
+ arglist = ['--type', self.volume_type.id, self.new_volume.id]
verifylist = [
('retype_policy', None),
('type', self.volume_type.id),
- ('volume', self.new_volume.id)
+ ('volume', self.new_volume.id),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
result = self.cmd.take_action(parsed_args)
self.volumes_mock.retype.assert_called_once_with(
- self.new_volume.id,
- self.volume_type.id,
- 'never')
+ self.new_volume.id, self.volume_type.id, 'never'
+ )
self.assertIsNone(result)
def test_volume_set_type_with_policy(self):
arglist = [
- '--retype-policy', 'on-demand',
- '--type', self.volume_type.id,
- self.new_volume.id
+ '--retype-policy',
+ 'on-demand',
+ '--type',
+ self.volume_type.id,
+ self.new_volume.id,
]
verifylist = [
('retype_policy', 'on-demand'),
('type', self.volume_type.id),
- ('volume', self.new_volume.id)
+ ('volume', self.new_volume.id),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
result = self.cmd.take_action(parsed_args)
self.volumes_mock.retype.assert_called_once_with(
- self.new_volume.id,
- self.volume_type.id,
- 'on-demand')
+ self.new_volume.id, self.volume_type.id, 'on-demand'
+ )
self.assertIsNone(result)
@mock.patch.object(volume.LOG, 'warning')
def test_volume_set_with_only_retype_policy(self, mock_warning):
- arglist = [
- '--retype-policy', 'on-demand',
- self.new_volume.id
- ]
+ arglist = ['--retype-policy', 'on-demand', self.new_volume.id]
verifylist = [
('retype_policy', 'on-demand'),
- ('volume', self.new_volume.id)
+ ('volume', self.new_volume.id),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
result = self.cmd.take_action(parsed_args)
self.volumes_mock.retype.assert_not_called()
- mock_warning.assert_called_with("'--retype-policy' option will "
- "not work without '--type' option")
+ mock_warning.assert_called_with(
+ "'--retype-policy' option will " "not work without '--type' option"
+ )
self.assertIsNone(result)
class TestVolumeShow(TestVolume):
-
def setUp(self):
super().setUp()
@@ -1587,12 +1654,8 @@ class TestVolumeShow(TestVolume):
self.cmd = volume.ShowVolume(self.app, None)
def test_volume_show(self):
- arglist = [
- self._volume.id
- ]
- verifylist = [
- ("volume", self._volume.id)
- ]
+ arglist = [self._volume.id]
+ verifylist = [("volume", self._volume.id)]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
columns, data = self.cmd.take_action(parsed_args)
@@ -1609,7 +1672,6 @@ class TestVolumeShow(TestVolume):
class TestVolumeUnset(TestVolume):
-
def setUp(self):
super().setUp()
@@ -1623,11 +1685,12 @@ class TestVolumeUnset(TestVolume):
self.cmd_unset = volume.UnsetVolume(self.app, None)
def test_volume_unset_image_property(self):
-
# Arguments for setting image properties
arglist = [
- '--image-property', 'Alpha=a',
- '--image-property', 'Beta=b',
+ '--image-property',
+ 'Alpha=a',
+ '--image-property',
+ 'Beta=b',
self.new_volume.id,
]
verifylist = [
@@ -1642,30 +1705,35 @@ class TestVolumeUnset(TestVolume):
# Arguments for unsetting image properties
arglist_unset = [
- '--image-property', 'Alpha',
+ '--image-property',
+ 'Alpha',
self.new_volume.id,
]
verifylist_unset = [
('image_property', ['Alpha']),
('volume', self.new_volume.id),
]
- parsed_args_unset = self.check_parser(self.cmd_unset,
- arglist_unset,
- verifylist_unset)
+ parsed_args_unset = self.check_parser(
+ self.cmd_unset, arglist_unset, verifylist_unset
+ )
# In base command class ShowOne in cliff, abstract method take_action()
# returns nothing
self.cmd_unset.take_action(parsed_args_unset)
self.volumes_mock.delete_image_metadata.assert_called_with(
- self.new_volume.id, parsed_args_unset.image_property)
+ self.new_volume.id, parsed_args_unset.image_property
+ )
def test_volume_unset_image_property_fail(self):
self.volumes_mock.delete_image_metadata.side_effect = (
- exceptions.CommandError())
+ exceptions.CommandError()
+ )
arglist = [
- '--image-property', 'Alpha',
- '--property', 'Beta',
+ '--image-property',
+ 'Alpha',
+ '--property',
+ 'Beta',
self.new_volume.id,
]
verifylist = [
@@ -1673,31 +1741,33 @@ class TestVolumeUnset(TestVolume):
('property', ['Beta']),
('volume', self.new_volume.id),
]
- parsed_args = self.check_parser(
- self.cmd_unset, arglist, verifylist)
+ parsed_args = self.check_parser(self.cmd_unset, arglist, verifylist)
try:
self.cmd_unset.take_action(parsed_args)
self.fail('CommandError should be raised.')
except exceptions.CommandError as e:
- self.assertEqual('One or more of the unset operations failed',
- str(e))
+ self.assertEqual(
+ 'One or more of the unset operations failed', str(e)
+ )
self.volumes_mock.delete_image_metadata.assert_called_with(
- self.new_volume.id, parsed_args.image_property)
+ self.new_volume.id, parsed_args.image_property
+ )
self.volumes_mock.delete_metadata.assert_called_with(
- self.new_volume.id, parsed_args.property)
+ self.new_volume.id, parsed_args.property
+ )
class TestColumns(TestVolume):
-
def test_attachments_column_without_server_cache(self):
_volume = volume_fakes.create_one_volume()
server_id = _volume.attachments[0]['server_id']
device = _volume.attachments[0]['device']
col = volume.AttachmentsColumn(_volume.attachments, {})
- self.assertEqual('Attached to %s on %s ' % (server_id, device),
- col.human_readable())
+ self.assertEqual(
+ 'Attached to %s on %s ' % (server_id, device), col.human_readable()
+ )
self.assertEqual(_volume.attachments, col.machine_readable())
def test_attachments_column_with_server_cache(self):
@@ -1712,5 +1782,6 @@ class TestColumns(TestVolume):
col = volume.AttachmentsColumn(_volume.attachments, server_cache)
self.assertEqual(
'Attached to %s on %s ' % ('fake-server-name', device),
- col.human_readable())
+ col.human_readable(),
+ )
self.assertEqual(_volume.attachments, col.machine_readable())
diff --git a/openstackclient/tests/unit/volume/v2/test_volume_backend.py b/openstackclient/tests/unit/volume/v2/test_volume_backend.py
index 6c64f645..5c80d9e6 100644
--- a/openstackclient/tests/unit/volume/v2/test_volume_backend.py
+++ b/openstackclient/tests/unit/volume/v2/test_volume_backend.py
@@ -105,9 +105,7 @@ class TestListVolumePool(volume_fakes.TestVolume):
# confirming if all expected columns are present in the result.
self.assertEqual(expected_columns, columns)
- datalist = ((
- self.pools.name,
- ), )
+ datalist = ((self.pools.name,),)
# confirming if all expected values are present in the result.
self.assertEqual(datalist, tuple(data))
@@ -122,12 +120,8 @@ class TestListVolumePool(volume_fakes.TestVolume):
self.assertNotIn("storage_protocol", columns)
def test_service_list_with_long_option(self):
- arglist = [
- '--long'
- ]
- verifylist = [
- ('long', True)
- ]
+ arglist = ['--long']
+ verifylist = [('long', True)]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
# In base command class Lister in cliff, abstract method take_action()
@@ -149,16 +143,18 @@ class TestListVolumePool(volume_fakes.TestVolume):
# confirming if all expected columns are present in the result.
self.assertEqual(expected_columns, columns)
- datalist = ((
- self.pools.name,
- self.pools.storage_protocol,
- self.pools.thick_provisioning_support,
- self.pools.thin_provisioning_support,
- self.pools.total_volumes,
- self.pools.total_capacity_gb,
- self.pools.allocated_capacity_gb,
- self.pools.max_over_subscription_ratio,
- ), )
+ datalist = (
+ (
+ self.pools.name,
+ self.pools.storage_protocol,
+ self.pools.thick_provisioning_support,
+ self.pools.thin_provisioning_support,
+ self.pools.total_volumes,
+ self.pools.total_capacity_gb,
+ self.pools.allocated_capacity_gb,
+ self.pools.max_over_subscription_ratio,
+ ),
+ )
# confirming if all expected values are present in the result.
self.assertEqual(datalist, tuple(data))
diff --git a/openstackclient/tests/unit/volume/v2/test_volume_backup.py b/openstackclient/tests/unit/volume/v2/test_volume_backup.py
index 7d00b8bf..82adea1f 100644
--- a/openstackclient/tests/unit/volume/v2/test_volume_backup.py
+++ b/openstackclient/tests/unit/volume/v2/test_volume_backup.py
@@ -24,7 +24,6 @@ from openstackclient.volume.v2 import volume_backup
class TestBackup(volume_fakes.TestVolume):
-
def setUp(self):
super().setUp()
@@ -39,11 +38,11 @@ class TestBackup(volume_fakes.TestVolume):
class TestBackupCreate(TestBackup):
-
volume = volume_fakes.create_one_volume()
snapshot = volume_fakes.create_one_snapshot()
new_backup = volume_fakes.create_one_backup(
- attrs={'volume_id': volume.id, 'snapshot_id': snapshot.id})
+ attrs={'volume_id': volume.id, 'snapshot_id': snapshot.id}
+ )
columns = (
'availability_zone',
@@ -82,12 +81,16 @@ class TestBackupCreate(TestBackup):
def test_backup_create(self):
arglist = [
- "--name", self.new_backup.name,
- "--description", self.new_backup.description,
- "--container", self.new_backup.container,
+ "--name",
+ self.new_backup.name,
+ "--description",
+ self.new_backup.description,
+ "--container",
+ self.new_backup.container,
"--force",
"--incremental",
- "--snapshot", self.new_backup.snapshot_id,
+ "--snapshot",
+ self.new_backup.snapshot_id,
self.new_backup.volume_id,
]
verifylist = [
@@ -116,12 +119,15 @@ class TestBackupCreate(TestBackup):
self.assertEqual(self.data, data)
def test_backup_create_with_properties(self):
- self.app.client_manager.volume.api_version = \
- api_versions.APIVersion('3.43')
+ self.app.client_manager.volume.api_version = api_versions.APIVersion(
+ '3.43'
+ )
arglist = [
- "--property", "foo=bar",
- "--property", "wow=much-cool",
+ "--property",
+ "foo=bar",
+ "--property",
+ "wow=much-cool",
self.new_backup.volume_id,
]
verifylist = [
@@ -145,12 +151,15 @@ class TestBackupCreate(TestBackup):
self.assertEqual(self.data, data)
def test_backup_create_with_properties_pre_v343(self):
- self.app.client_manager.volume.api_version = \
- api_versions.APIVersion('3.42')
+ self.app.client_manager.volume.api_version = api_versions.APIVersion(
+ '3.42'
+ )
arglist = [
- "--property", "foo=bar",
- "--property", "wow=much-cool",
+ "--property",
+ "foo=bar",
+ "--property",
+ "wow=much-cool",
self.new_backup.volume_id,
]
verifylist = [
@@ -160,17 +169,18 @@ class TestBackupCreate(TestBackup):
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
exc = self.assertRaises(
- exceptions.CommandError,
- self.cmd.take_action,
- parsed_args)
+ exceptions.CommandError, self.cmd.take_action, parsed_args
+ )
self.assertIn("--os-volume-api-version 3.43 or greater", str(exc))
def test_backup_create_with_availability_zone(self):
- self.app.client_manager.volume.api_version = \
- api_versions.APIVersion('3.51')
+ self.app.client_manager.volume.api_version = api_versions.APIVersion(
+ '3.51'
+ )
arglist = [
- "--availability-zone", "my-az",
+ "--availability-zone",
+ "my-az",
self.new_backup.volume_id,
]
verifylist = [
@@ -194,11 +204,13 @@ class TestBackupCreate(TestBackup):
self.assertEqual(self.data, data)
def test_backup_create_with_availability_zone_pre_v351(self):
- self.app.client_manager.volume.api_version = \
- api_versions.APIVersion('3.50')
+ self.app.client_manager.volume.api_version = api_versions.APIVersion(
+ '3.50'
+ )
arglist = [
- "--availability-zone", "my-az",
+ "--availability-zone",
+ "my-az",
self.new_backup.volume_id,
]
verifylist = [
@@ -208,15 +220,16 @@ class TestBackupCreate(TestBackup):
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
exc = self.assertRaises(
- exceptions.CommandError,
- self.cmd.take_action,
- parsed_args)
+ exceptions.CommandError, self.cmd.take_action, parsed_args
+ )
self.assertIn("--os-volume-api-version 3.51 or greater", str(exc))
def test_backup_create_without_name(self):
arglist = [
- "--description", self.new_backup.description,
- "--container", self.new_backup.container,
+ "--description",
+ self.new_backup.description,
+ "--container",
+ self.new_backup.container,
self.new_backup.volume_id,
]
verifylist = [
@@ -241,32 +254,25 @@ class TestBackupCreate(TestBackup):
class TestBackupDelete(TestBackup):
-
backups = volume_fakes.create_backups(count=2)
def setUp(self):
super().setUp()
- self.backups_mock.get = (
- volume_fakes.get_backups(self.backups))
+ self.backups_mock.get = volume_fakes.get_backups(self.backups)
self.backups_mock.delete.return_value = None
# Get the command object to mock
self.cmd = volume_backup.DeleteVolumeBackup(self.app, None)
def test_backup_delete(self):
- arglist = [
- self.backups[0].id
- ]
- verifylist = [
- ("backups", [self.backups[0].id])
- ]
+ arglist = [self.backups[0].id]
+ verifylist = [("backups", [self.backups[0].id])]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
result = self.cmd.take_action(parsed_args)
- self.backups_mock.delete.assert_called_with(
- self.backups[0].id, False)
+ self.backups_mock.delete.assert_called_with(self.backups[0].id, False)
self.assertIsNone(result)
def test_backup_delete_with_force(self):
@@ -274,10 +280,7 @@ class TestBackupDelete(TestBackup):
'--force',
self.backups[0].id,
]
- verifylist = [
- ('force', True),
- ("backups", [self.backups[0].id])
- ]
+ verifylist = [('force', True), ("backups", [self.backups[0].id])]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
result = self.cmd.take_action(parsed_args)
@@ -314,14 +317,14 @@ class TestBackupDelete(TestBackup):
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
find_mock_result = [self.backups[0], exceptions.CommandError]
- with mock.patch.object(utils, 'find_resource',
- side_effect=find_mock_result) as find_mock:
+ with mock.patch.object(
+ utils, 'find_resource', side_effect=find_mock_result
+ ) as find_mock:
try:
self.cmd.take_action(parsed_args)
self.fail('CommandError should be raised.')
except exceptions.CommandError as e:
- self.assertEqual('1 of 2 backups failed to delete.',
- str(e))
+ self.assertEqual('1 of 2 backups failed to delete.', str(e))
find_mock.assert_any_call(self.backups_mock, self.backups[0].id)
find_mock.assert_any_call(self.backups_mock, 'unexist_backup')
@@ -333,10 +336,10 @@ class TestBackupDelete(TestBackup):
class TestBackupList(TestBackup):
-
volume = volume_fakes.create_one_volume()
backups = volume_fakes.create_backups(
- attrs={'volume_id': volume.name}, count=3)
+ attrs={'volume_id': volume.name}, count=3
+ )
columns = (
'ID',
@@ -353,25 +356,29 @@ class TestBackupList(TestBackup):
data = []
for b in backups:
- data.append((
- b.id,
- b.name,
- b.description,
- b.status,
- b.size,
- ))
+ data.append(
+ (
+ b.id,
+ b.name,
+ b.description,
+ b.status,
+ b.size,
+ )
+ )
data_long = []
for b in backups:
- data_long.append((
- b.id,
- b.name,
- b.description,
- b.status,
- b.size,
- b.availability_zone,
- volume_backup.VolumeIdColumn(b.volume_id),
- b.container,
- ))
+ data_long.append(
+ (
+ b.id,
+ b.name,
+ b.description,
+ b.status,
+ b.size,
+ b.availability_zone,
+ volume_backup.VolumeIdColumn(b.volume_id),
+ b.container,
+ )
+ )
def setUp(self):
super().setUp()
@@ -417,12 +424,17 @@ class TestBackupList(TestBackup):
def test_backup_list_with_options(self):
arglist = [
"--long",
- "--name", self.backups[0].name,
- "--status", "error",
- "--volume", self.volume.id,
- "--marker", self.backups[0].id,
+ "--name",
+ self.backups[0].name,
+ "--status",
+ "error",
+ "--volume",
+ self.volume.id,
+ "--marker",
+ self.backups[0].id,
"--all-projects",
- "--limit", "3",
+ "--limit",
+ "3",
]
verifylist = [
("long", True),
@@ -455,7 +467,6 @@ class TestBackupList(TestBackup):
class TestBackupRestore(TestBackup):
-
volume = volume_fakes.create_one_volume()
backup = volume_fakes.create_one_backup(
attrs={'volume_id': volume.id},
@@ -477,9 +488,7 @@ class TestBackupRestore(TestBackup):
def test_backup_restore(self):
self.volumes_mock.get.side_effect = exceptions.CommandError()
self.volumes_mock.find.side_effect = exceptions.CommandError()
- arglist = [
- self.backup.id
- ]
+ arglist = [self.backup.id]
verifylist = [
("backup", self.backup.id),
("volume", None),
@@ -488,7 +497,9 @@ class TestBackupRestore(TestBackup):
result = self.cmd.take_action(parsed_args)
self.restores_mock.restore.assert_called_with(
- self.backup.id, None, None,
+ self.backup.id,
+ None,
+ None,
)
self.assertIsNotNone(result)
@@ -507,7 +518,9 @@ class TestBackupRestore(TestBackup):
result = self.cmd.take_action(parsed_args)
self.restores_mock.restore.assert_called_with(
- self.backup.id, None, self.backup.volume_id,
+ self.backup.id,
+ None,
+ self.backup.volume_id,
)
self.assertIsNotNone(result)
@@ -526,7 +539,9 @@ class TestBackupRestore(TestBackup):
result = self.cmd.take_action(parsed_args)
self.restores_mock.restore.assert_called_with(
- self.backup.id, self.volume.id, None,
+ self.backup.id,
+ self.volume.id,
+ None,
)
self.assertIsNotNone(result)
@@ -549,7 +564,6 @@ class TestBackupRestore(TestBackup):
class TestBackupSet(TestBackup):
-
backup = volume_fakes.create_one_backup(
attrs={'metadata': {'wow': 'cool'}},
)
@@ -563,11 +577,13 @@ class TestBackupSet(TestBackup):
self.cmd = volume_backup.SetVolumeBackup(self.app, None)
def test_backup_set_name(self):
- self.app.client_manager.volume.api_version = \
- api_versions.APIVersion('3.9')
+ self.app.client_manager.volume.api_version = api_versions.APIVersion(
+ '3.9'
+ )
arglist = [
- '--name', 'new_name',
+ '--name',
+ 'new_name',
self.backup.id,
]
verifylist = [
@@ -580,15 +596,18 @@ class TestBackupSet(TestBackup):
# returns nothing
result = self.cmd.take_action(parsed_args)
self.backups_mock.update.assert_called_once_with(
- self.backup.id, **{'name': 'new_name'})
+ self.backup.id, **{'name': 'new_name'}
+ )
self.assertIsNone(result)
def test_backup_set_name_pre_v39(self):
- self.app.client_manager.volume.api_version = \
- api_versions.APIVersion('3.8')
+ self.app.client_manager.volume.api_version = api_versions.APIVersion(
+ '3.8'
+ )
arglist = [
- '--name', 'new_name',
+ '--name',
+ 'new_name',
self.backup.id,
]
verifylist = [
@@ -598,17 +617,18 @@ class TestBackupSet(TestBackup):
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
exc = self.assertRaises(
- exceptions.CommandError,
- self.cmd.take_action,
- parsed_args)
+ exceptions.CommandError, self.cmd.take_action, parsed_args
+ )
self.assertIn("--os-volume-api-version 3.9 or greater", str(exc))
def test_backup_set_description(self):
- self.app.client_manager.volume.api_version = \
- api_versions.APIVersion('3.9')
+ self.app.client_manager.volume.api_version = api_versions.APIVersion(
+ '3.9'
+ )
arglist = [
- '--description', 'new_description',
+ '--description',
+ 'new_description',
self.backup.id,
]
verifylist = [
@@ -621,21 +641,20 @@ class TestBackupSet(TestBackup):
result = self.cmd.take_action(parsed_args)
# Set expected values
- kwargs = {
- 'description': 'new_description'
- }
+ kwargs = {'description': 'new_description'}
self.backups_mock.update.assert_called_once_with(
- self.backup.id,
- **kwargs
+ self.backup.id, **kwargs
)
self.assertIsNone(result)
def test_backup_set_description_pre_v39(self):
- self.app.client_manager.volume.api_version = \
- api_versions.APIVersion('3.8')
+ self.app.client_manager.volume.api_version = api_versions.APIVersion(
+ '3.8'
+ )
arglist = [
- '--description', 'new_description',
+ '--description',
+ 'new_description',
self.backup.id,
]
verifylist = [
@@ -646,52 +665,43 @@ class TestBackupSet(TestBackup):
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
exc = self.assertRaises(
- exceptions.CommandError,
- self.cmd.take_action,
- parsed_args)
+ exceptions.CommandError, self.cmd.take_action, parsed_args
+ )
self.assertIn("--os-volume-api-version 3.9 or greater", str(exc))
def test_backup_set_state(self):
- arglist = [
- '--state', 'error',
- self.backup.id
- ]
- verifylist = [
- ('state', 'error'),
- ('backup', self.backup.id)
- ]
+ arglist = ['--state', 'error', self.backup.id]
+ verifylist = [('state', 'error'), ('backup', self.backup.id)]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
result = self.cmd.take_action(parsed_args)
self.backups_mock.reset_state.assert_called_once_with(
- self.backup.id, 'error')
+ self.backup.id, 'error'
+ )
self.assertIsNone(result)
def test_backup_set_state_failed(self):
self.backups_mock.reset_state.side_effect = exceptions.CommandError()
- arglist = [
- '--state', 'error',
- self.backup.id
- ]
- verifylist = [
- ('state', 'error'),
- ('backup', self.backup.id)
- ]
+ arglist = ['--state', 'error', self.backup.id]
+ verifylist = [('state', 'error'), ('backup', self.backup.id)]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
try:
self.cmd.take_action(parsed_args)
self.fail('CommandError should be raised.')
except exceptions.CommandError as e:
- self.assertEqual('One or more of the set operations failed',
- str(e))
+ self.assertEqual(
+ 'One or more of the set operations failed', str(e)
+ )
self.backups_mock.reset_state.assert_called_with(
- self.backup.id, 'error')
+ self.backup.id, 'error'
+ )
def test_backup_set_no_property(self):
- self.app.client_manager.volume.api_version = \
- api_versions.APIVersion('3.43')
+ self.app.client_manager.volume.api_version = api_versions.APIVersion(
+ '3.43'
+ )
arglist = [
'--no-property',
@@ -710,14 +720,14 @@ class TestBackupSet(TestBackup):
'metadata': {},
}
self.backups_mock.update.assert_called_once_with(
- self.backup.id,
- **kwargs
+ self.backup.id, **kwargs
)
self.assertIsNone(result)
def test_backup_set_no_property_pre_v343(self):
- self.app.client_manager.volume.api_version = \
- api_versions.APIVersion('3.42')
+ self.app.client_manager.volume.api_version = api_versions.APIVersion(
+ '3.42'
+ )
arglist = [
'--no-property',
@@ -730,17 +740,18 @@ class TestBackupSet(TestBackup):
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
exc = self.assertRaises(
- exceptions.CommandError,
- self.cmd.take_action,
- parsed_args)
+ exceptions.CommandError, self.cmd.take_action, parsed_args
+ )
self.assertIn("--os-volume-api-version 3.43 or greater", str(exc))
def test_backup_set_property(self):
- self.app.client_manager.volume.api_version = \
- api_versions.APIVersion('3.43')
+ self.app.client_manager.volume.api_version = api_versions.APIVersion(
+ '3.43'
+ )
arglist = [
- '--property', 'foo=bar',
+ '--property',
+ 'foo=bar',
self.backup.id,
]
verifylist = [
@@ -756,17 +767,18 @@ class TestBackupSet(TestBackup):
'metadata': {'wow': 'cool', 'foo': 'bar'},
}
self.backups_mock.update.assert_called_once_with(
- self.backup.id,
- **kwargs
+ self.backup.id, **kwargs
)
self.assertIsNone(result)
def test_backup_set_property_pre_v343(self):
- self.app.client_manager.volume.api_version = \
- api_versions.APIVersion('3.42')
+ self.app.client_manager.volume.api_version = api_versions.APIVersion(
+ '3.42'
+ )
arglist = [
- '--property', 'foo=bar',
+ '--property',
+ 'foo=bar',
self.backup.id,
]
verifylist = [
@@ -776,14 +788,12 @@ class TestBackupSet(TestBackup):
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
exc = self.assertRaises(
- exceptions.CommandError,
- self.cmd.take_action,
- parsed_args)
+ exceptions.CommandError, self.cmd.take_action, parsed_args
+ )
self.assertIn("--os-volume-api-version 3.43 or greater", str(exc))
class TestBackupUnset(TestBackup):
-
backup = volume_fakes.create_one_backup(
attrs={'metadata': {'foo': 'bar'}},
)
@@ -797,11 +807,13 @@ class TestBackupUnset(TestBackup):
self.cmd = volume_backup.UnsetVolumeBackup(self.app, None)
def test_backup_unset_property(self):
- self.app.client_manager.volume.api_version = \
- api_versions.APIVersion('3.43')
+ self.app.client_manager.volume.api_version = api_versions.APIVersion(
+ '3.43'
+ )
arglist = [
- '--property', 'foo',
+ '--property',
+ 'foo',
self.backup.id,
]
verifylist = [
@@ -817,17 +829,18 @@ class TestBackupUnset(TestBackup):
'metadata': {},
}
self.backups_mock.update.assert_called_once_with(
- self.backup.id,
- **kwargs
+ self.backup.id, **kwargs
)
self.assertIsNone(result)
def test_backup_unset_property_pre_v343(self):
- self.app.client_manager.volume.api_version = \
- api_versions.APIVersion('3.42')
+ self.app.client_manager.volume.api_version = api_versions.APIVersion(
+ '3.42'
+ )
arglist = [
- '--property', 'foo',
+ '--property',
+ 'foo',
self.backup.id,
]
verifylist = [
@@ -837,14 +850,12 @@ class TestBackupUnset(TestBackup):
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
exc = self.assertRaises(
- exceptions.CommandError,
- self.cmd.take_action,
- parsed_args)
+ exceptions.CommandError, self.cmd.take_action, parsed_args
+ )
self.assertIn("--os-volume-api-version 3.43 or greater", str(exc))
class TestBackupShow(TestBackup):
-
backup = volume_fakes.create_one_backup()
columns = (
@@ -880,12 +891,8 @@ class TestBackupShow(TestBackup):
self.cmd = volume_backup.ShowVolumeBackup(self.app, None)
def test_backup_show(self):
- arglist = [
- self.backup.id
- ]
- verifylist = [
- ("backup", self.backup.id)
- ]
+ arglist = [self.backup.id]
+ verifylist = [("backup", self.backup.id)]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
columns, data = self.cmd.take_action(parsed_args)
diff --git a/openstackclient/tests/unit/volume/v2/test_volume_host.py b/openstackclient/tests/unit/volume/v2/test_volume_host.py
index 730085a3..7d976c91 100644
--- a/openstackclient/tests/unit/volume/v2/test_volume_host.py
+++ b/openstackclient/tests/unit/volume/v2/test_volume_host.py
@@ -17,7 +17,6 @@ from openstackclient.volume.v2 import volume_host
class TestVolumeHost(volume_fakes.TestVolume):
-
def setUp(self):
super().setUp()
@@ -26,7 +25,6 @@ class TestVolumeHost(volume_fakes.TestVolume):
class TestVolumeHostSet(TestVolumeHost):
-
service = volume_fakes.create_one_service()
def setUp(self):
@@ -88,7 +86,6 @@ class TestVolumeHostSet(TestVolumeHost):
class TestVolumeHostFailover(TestVolumeHost):
-
service = volume_fakes.create_one_service()
def setUp(self):
@@ -101,7 +98,8 @@ class TestVolumeHostFailover(TestVolumeHost):
def test_volume_host_failover(self):
arglist = [
- '--volume-backend', 'backend_test',
+ '--volume-backend',
+ 'backend_test',
self.service.host,
]
verifylist = [
@@ -113,5 +111,6 @@ class TestVolumeHostFailover(TestVolumeHost):
result = self.cmd.take_action(parsed_args)
self.host_mock.failover_host.assert_called_with(
- self.service.host, 'backend_test')
+ self.service.host, 'backend_test'
+ )
self.assertIsNone(result)
diff --git a/openstackclient/tests/unit/volume/v2/test_volume_snapshot.py b/openstackclient/tests/unit/volume/v2/test_volume_snapshot.py
index 6cffcaac..f8120a15 100644
--- a/openstackclient/tests/unit/volume/v2/test_volume_snapshot.py
+++ b/openstackclient/tests/unit/volume/v2/test_volume_snapshot.py
@@ -26,7 +26,6 @@ from openstackclient.volume.v2 import volume_snapshot
class TestVolumeSnapshot(volume_fakes.TestVolume):
-
def setUp(self):
super().setUp()
@@ -39,7 +38,6 @@ class TestVolumeSnapshot(volume_fakes.TestVolume):
class TestVolumeSnapshotCreate(TestVolumeSnapshot):
-
columns = (
'created_at',
'description',
@@ -56,7 +54,8 @@ class TestVolumeSnapshotCreate(TestVolumeSnapshot):
self.volume = volume_fakes.create_one_volume()
self.new_snapshot = volume_fakes.create_one_snapshot(
- attrs={'volume_id': self.volume.id})
+ attrs={'volume_id': self.volume.id}
+ )
self.data = (
self.new_snapshot.created_at,
@@ -77,11 +76,15 @@ class TestVolumeSnapshotCreate(TestVolumeSnapshot):
def test_snapshot_create(self):
arglist = [
- "--volume", self.new_snapshot.volume_id,
- "--description", self.new_snapshot.description,
+ "--volume",
+ self.new_snapshot.volume_id,
+ "--description",
+ self.new_snapshot.description,
"--force",
- '--property', 'Alpha=a',
- '--property', 'Beta=b',
+ '--property',
+ 'Alpha=a',
+ '--property',
+ 'Beta=b',
self.new_snapshot.name,
]
verifylist = [
@@ -107,7 +110,8 @@ class TestVolumeSnapshotCreate(TestVolumeSnapshot):
def test_snapshot_create_without_name(self):
arglist = [
- "--volume", self.new_snapshot.volume_id,
+ "--volume",
+ self.new_snapshot.volume_id,
]
verifylist = [
("volume", self.new_snapshot.volume_id),
@@ -122,21 +126,21 @@ class TestVolumeSnapshotCreate(TestVolumeSnapshot):
def test_snapshot_create_without_volume(self):
arglist = [
- "--description", self.new_snapshot.description,
+ "--description",
+ self.new_snapshot.description,
"--force",
- self.new_snapshot.name
+ self.new_snapshot.name,
]
verifylist = [
("description", self.new_snapshot.description),
("force", True),
- ("snapshot_name", self.new_snapshot.name)
+ ("snapshot_name", self.new_snapshot.name),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
columns, data = self.cmd.take_action(parsed_args)
- self.volumes_mock.get.assert_called_once_with(
- self.new_snapshot.name)
+ self.volumes_mock.get.assert_called_once_with(self.new_snapshot.name)
self.snapshots_mock.create.assert_called_once_with(
self.new_snapshot.volume_id,
force=True,
@@ -149,13 +153,18 @@ class TestVolumeSnapshotCreate(TestVolumeSnapshot):
def test_snapshot_create_with_remote_source(self):
arglist = [
- '--remote-source', 'source-name=test_source_name',
- '--remote-source', 'source-id=test_source_id',
- '--volume', self.new_snapshot.volume_id,
+ '--remote-source',
+ 'source-name=test_source_name',
+ '--remote-source',
+ 'source-id=test_source_id',
+ '--volume',
+ self.new_snapshot.volume_id,
self.new_snapshot.name,
]
- ref_dict = {'source-name': 'test_source_name',
- 'source-id': 'test_source_id'}
+ ref_dict = {
+ 'source-name': 'test_source_name',
+ 'source-id': 'test_source_id',
+ }
verifylist = [
('remote_source', ref_dict),
('volume', self.new_snapshot.volume_id),
@@ -178,49 +187,39 @@ class TestVolumeSnapshotCreate(TestVolumeSnapshot):
class TestVolumeSnapshotDelete(TestVolumeSnapshot):
-
snapshots = volume_fakes.create_snapshots(count=2)
def setUp(self):
super().setUp()
- self.snapshots_mock.get = (
- volume_fakes.get_snapshots(self.snapshots))
+ self.snapshots_mock.get = volume_fakes.get_snapshots(self.snapshots)
self.snapshots_mock.delete.return_value = None
# Get the command object to mock
self.cmd = volume_snapshot.DeleteVolumeSnapshot(self.app, None)
def test_snapshot_delete(self):
- arglist = [
- self.snapshots[0].id
- ]
- verifylist = [
- ("snapshots", [self.snapshots[0].id])
- ]
+ arglist = [self.snapshots[0].id]
+ verifylist = [("snapshots", [self.snapshots[0].id])]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
result = self.cmd.take_action(parsed_args)
self.snapshots_mock.delete.assert_called_with(
- self.snapshots[0].id, False)
+ self.snapshots[0].id, False
+ )
self.assertIsNone(result)
def test_snapshot_delete_with_force(self):
- arglist = [
- '--force',
- self.snapshots[0].id
- ]
- verifylist = [
- ('force', True),
- ("snapshots", [self.snapshots[0].id])
- ]
+ arglist = ['--force', self.snapshots[0].id]
+ verifylist = [('force', True), ("snapshots", [self.snapshots[0].id])]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
result = self.cmd.take_action(parsed_args)
self.snapshots_mock.delete.assert_called_with(
- self.snapshots[0].id, True)
+ self.snapshots[0].id, True
+ )
self.assertIsNone(result)
def test_delete_multiple_snapshots(self):
@@ -252,17 +251,18 @@ class TestVolumeSnapshotDelete(TestVolumeSnapshot):
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
find_mock_result = [self.snapshots[0], exceptions.CommandError]
- with mock.patch.object(utils, 'find_resource',
- side_effect=find_mock_result) as find_mock:
+ with mock.patch.object(
+ utils, 'find_resource', side_effect=find_mock_result
+ ) as find_mock:
try:
self.cmd.take_action(parsed_args)
self.fail('CommandError should be raised.')
except exceptions.CommandError as e:
- self.assertEqual('1 of 2 snapshots failed to delete.',
- str(e))
+ self.assertEqual('1 of 2 snapshots failed to delete.', str(e))
find_mock.assert_any_call(
- self.snapshots_mock, self.snapshots[0].id)
+ self.snapshots_mock, self.snapshots[0].id
+ )
find_mock.assert_any_call(self.snapshots_mock, 'unexist_snapshot')
self.assertEqual(2, find_mock.call_count)
@@ -272,47 +272,42 @@ class TestVolumeSnapshotDelete(TestVolumeSnapshot):
class TestVolumeSnapshotList(TestVolumeSnapshot):
-
volume = volume_fakes.create_one_volume()
project = project_fakes.FakeProject.create_one_project()
snapshots = volume_fakes.create_snapshots(
- attrs={'volume_id': volume.name}, count=3)
-
- columns = [
- "ID",
- "Name",
- "Description",
- "Status",
- "Size"
- ]
- columns_long = columns + [
- "Created At",
- "Volume",
- "Properties"
- ]
+ attrs={'volume_id': volume.name}, count=3
+ )
+
+ columns = ["ID", "Name", "Description", "Status", "Size"]
+ columns_long = columns + ["Created At", "Volume", "Properties"]
data = []
for s in snapshots:
- data.append((
- s.id,
- s.name,
- s.description,
- s.status,
- s.size,
- ))
+ data.append(
+ (
+ s.id,
+ s.name,
+ s.description,
+ s.status,
+ s.size,
+ )
+ )
data_long = []
for s in snapshots:
- data_long.append((
- s.id,
- s.name,
- s.description,
- s.status,
- s.size,
- s.created_at,
- volume_snapshot.VolumeIdColumn(
- s.volume_id, volume_cache={volume.id: volume}),
- format_columns.DictColumn(s.metadata),
- ))
+ data_long.append(
+ (
+ s.id,
+ s.name,
+ s.description,
+ s.status,
+ s.size,
+ s.created_at,
+ volume_snapshot.VolumeIdColumn(
+ s.volume_id, volume_cache={volume.id: volume}
+ ),
+ format_columns.DictColumn(s.metadata),
+ )
+ )
def setUp(self):
super().setUp()
@@ -326,23 +321,21 @@ class TestVolumeSnapshotList(TestVolumeSnapshot):
def test_snapshot_list_without_options(self):
arglist = []
- verifylist = [
- ('all_projects', False),
- ('long', False)
- ]
+ verifylist = [('all_projects', False), ('long', False)]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
columns, data = self.cmd.take_action(parsed_args)
self.snapshots_mock.list.assert_called_once_with(
- limit=None, marker=None,
+ limit=None,
+ marker=None,
search_opts={
'all_tenants': False,
'name': None,
'status': None,
'project_id': None,
- 'volume_id': None
- }
+ 'volume_id': None,
+ },
)
self.assertEqual(self.columns, columns)
self.assertEqual(self.data, list(data))
@@ -350,9 +343,12 @@ class TestVolumeSnapshotList(TestVolumeSnapshot):
def test_snapshot_list_with_options(self):
arglist = [
"--long",
- "--limit", "2",
- "--project", self.project.id,
- "--marker", self.snapshots[0].id,
+ "--limit",
+ "2",
+ "--project",
+ self.project.id,
+ "--marker",
+ self.snapshots[0].id,
]
verifylist = [
("long", True),
@@ -373,8 +369,8 @@ class TestVolumeSnapshotList(TestVolumeSnapshot):
'project_id': self.project.id,
'name': None,
'status': None,
- 'volume_id': None
- }
+ 'volume_id': None,
+ },
)
self.assertEqual(self.columns_long, columns)
self.assertEqual(self.data_long, list(data))
@@ -383,30 +379,29 @@ class TestVolumeSnapshotList(TestVolumeSnapshot):
arglist = [
'--all-projects',
]
- verifylist = [
- ('long', False),
- ('all_projects', True)
- ]
+ verifylist = [('long', False), ('all_projects', True)]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
columns, data = self.cmd.take_action(parsed_args)
self.snapshots_mock.list.assert_called_once_with(
- limit=None, marker=None,
+ limit=None,
+ marker=None,
search_opts={
'all_tenants': True,
'name': None,
'status': None,
'project_id': None,
- 'volume_id': None
- }
+ 'volume_id': None,
+ },
)
self.assertEqual(self.columns, columns)
self.assertEqual(self.data, list(data))
def test_snapshot_list_name_option(self):
arglist = [
- '--name', self.snapshots[0].name,
+ '--name',
+ self.snapshots[0].name,
]
verifylist = [
('all_projects', False),
@@ -418,21 +413,23 @@ class TestVolumeSnapshotList(TestVolumeSnapshot):
columns, data = self.cmd.take_action(parsed_args)
self.snapshots_mock.list.assert_called_once_with(
- limit=None, marker=None,
+ limit=None,
+ marker=None,
search_opts={
'all_tenants': False,
'name': self.snapshots[0].name,
'status': None,
'project_id': None,
- 'volume_id': None
- }
+ 'volume_id': None,
+ },
)
self.assertEqual(self.columns, columns)
self.assertEqual(self.data, list(data))
def test_snapshot_list_status_option(self):
arglist = [
- '--status', self.snapshots[0].status,
+ '--status',
+ self.snapshots[0].status,
]
verifylist = [
('all_projects', False),
@@ -444,21 +441,23 @@ class TestVolumeSnapshotList(TestVolumeSnapshot):
columns, data = self.cmd.take_action(parsed_args)
self.snapshots_mock.list.assert_called_once_with(
- limit=None, marker=None,
+ limit=None,
+ marker=None,
search_opts={
'all_tenants': False,
'name': None,
'status': self.snapshots[0].status,
'project_id': None,
- 'volume_id': None
- }
+ 'volume_id': None,
+ },
)
self.assertEqual(self.columns, columns)
self.assertEqual(self.data, list(data))
def test_snapshot_list_volumeid_option(self):
arglist = [
- '--volume', self.volume.id,
+ '--volume',
+ self.volume.id,
]
verifylist = [
('all_projects', False),
@@ -470,31 +469,37 @@ class TestVolumeSnapshotList(TestVolumeSnapshot):
columns, data = self.cmd.take_action(parsed_args)
self.snapshots_mock.list.assert_called_once_with(
- limit=None, marker=None,
+ limit=None,
+ marker=None,
search_opts={
'all_tenants': False,
'name': None,
'status': None,
'project_id': None,
- 'volume_id': self.volume.id
- }
+ 'volume_id': self.volume.id,
+ },
)
self.assertEqual(self.columns, columns)
self.assertEqual(self.data, list(data))
def test_snapshot_list_negative_limit(self):
arglist = [
- "--limit", "-2",
+ "--limit",
+ "-2",
]
verifylist = [
("limit", -2),
]
- self.assertRaises(argparse.ArgumentTypeError, self.check_parser,
- self.cmd, arglist, verifylist)
+ self.assertRaises(
+ argparse.ArgumentTypeError,
+ self.check_parser,
+ self.cmd,
+ arglist,
+ verifylist,
+ )
class TestVolumeSnapshotSet(TestVolumeSnapshot):
-
snapshot = volume_fakes.create_one_snapshot()
def setUp(self):
@@ -524,9 +529,12 @@ class TestVolumeSnapshotSet(TestVolumeSnapshot):
def test_snapshot_set_name_and_property(self):
arglist = [
- "--name", "new_snapshot",
- "--property", "x=y",
- "--property", "foo=foo",
+ "--name",
+ "new_snapshot",
+ "--property",
+ "x=y",
+ "--property",
+ "foo=foo",
self.snapshot.id,
]
new_property = {"x": "y", "foo": "foo"}
@@ -543,7 +551,8 @@ class TestVolumeSnapshotSet(TestVolumeSnapshot):
"name": "new_snapshot",
}
self.snapshots_mock.update.assert_called_with(
- self.snapshot.id, **kwargs)
+ self.snapshot.id, **kwargs
+ )
self.snapshots_mock.set_metadata.assert_called_with(
self.snapshot.id, new_property
)
@@ -573,7 +582,8 @@ class TestVolumeSnapshotSet(TestVolumeSnapshot):
def test_snapshot_set_with_no_property_and_property(self):
arglist = [
"--no-property",
- "--property", "foo_1=bar_1",
+ "--property",
+ "foo_1=bar_1",
self.snapshot.id,
]
verifylist = [
@@ -591,58 +601,52 @@ class TestVolumeSnapshotSet(TestVolumeSnapshot):
self.snapshot.id, ["foo"]
)
self.snapshots_mock.set_metadata.assert_called_once_with(
- self.snapshot.id, {"foo_1": "bar_1"})
+ self.snapshot.id, {"foo_1": "bar_1"}
+ )
self.assertIsNone(result)
def test_snapshot_set_state_to_error(self):
- arglist = [
- "--state", "error",
- self.snapshot.id
- ]
- verifylist = [
- ("state", "error"),
- ("snapshot", self.snapshot.id)
- ]
+ arglist = ["--state", "error", self.snapshot.id]
+ verifylist = [("state", "error"), ("snapshot", self.snapshot.id)]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
result = self.cmd.take_action(parsed_args)
self.snapshots_mock.reset_state.assert_called_with(
- self.snapshot.id, "error")
+ self.snapshot.id, "error"
+ )
self.assertIsNone(result)
def test_volume_set_state_failed(self):
self.snapshots_mock.reset_state.side_effect = exceptions.CommandError()
- arglist = [
- '--state', 'error',
- self.snapshot.id
- ]
- verifylist = [
- ('state', 'error'),
- ('snapshot', self.snapshot.id)
- ]
+ arglist = ['--state', 'error', self.snapshot.id]
+ verifylist = [('state', 'error'), ('snapshot', self.snapshot.id)]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
try:
self.cmd.take_action(parsed_args)
self.fail('CommandError should be raised.')
except exceptions.CommandError as e:
- self.assertEqual('One or more of the set operations failed',
- str(e))
+ self.assertEqual(
+ 'One or more of the set operations failed', str(e)
+ )
self.snapshots_mock.reset_state.assert_called_once_with(
- self.snapshot.id, 'error')
+ self.snapshot.id, 'error'
+ )
def test_volume_set_name_and_state_failed(self):
self.snapshots_mock.reset_state.side_effect = exceptions.CommandError()
arglist = [
- '--state', 'error',
- "--name", "new_snapshot",
- self.snapshot.id
+ '--state',
+ 'error',
+ "--name",
+ "new_snapshot",
+ self.snapshot.id,
]
verifylist = [
('state', 'error'),
("name", "new_snapshot"),
- ('snapshot', self.snapshot.id)
+ ('snapshot', self.snapshot.id),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -650,19 +654,21 @@ class TestVolumeSnapshotSet(TestVolumeSnapshot):
self.cmd.take_action(parsed_args)
self.fail('CommandError should be raised.')
except exceptions.CommandError as e:
- self.assertEqual('One or more of the set operations failed',
- str(e))
+ self.assertEqual(
+ 'One or more of the set operations failed', str(e)
+ )
kwargs = {
"name": "new_snapshot",
}
self.snapshots_mock.update.assert_called_once_with(
- self.snapshot.id, **kwargs)
+ self.snapshot.id, **kwargs
+ )
self.snapshots_mock.reset_state.assert_called_once_with(
- self.snapshot.id, 'error')
+ self.snapshot.id, 'error'
+ )
class TestVolumeSnapshotShow(TestVolumeSnapshot):
-
columns = (
'created_at',
'description',
@@ -695,12 +701,8 @@ class TestVolumeSnapshotShow(TestVolumeSnapshot):
self.cmd = volume_snapshot.ShowVolumeSnapshot(self.app, None)
def test_snapshot_show(self):
- arglist = [
- self.snapshot.id
- ]
- verifylist = [
- ("snapshot", self.snapshot.id)
- ]
+ arglist = [self.snapshot.id]
+ verifylist = [("snapshot", self.snapshot.id)]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
columns, data = self.cmd.take_action(parsed_args)
@@ -711,7 +713,6 @@ class TestVolumeSnapshotShow(TestVolumeSnapshot):
class TestVolumeSnapshotUnset(TestVolumeSnapshot):
-
snapshot = volume_fakes.create_one_snapshot()
def setUp(self):
@@ -724,7 +725,8 @@ class TestVolumeSnapshotUnset(TestVolumeSnapshot):
def test_snapshot_unset(self):
arglist = [
- "--property", "foo",
+ "--property",
+ "foo",
self.snapshot.id,
]
verifylist = [
diff --git a/openstackclient/tests/unit/volume/v2/test_volume_transfer_request.py b/openstackclient/tests/unit/volume/v2/test_volume_transfer_request.py
index c8c6fac9..706783bd 100644
--- a/openstackclient/tests/unit/volume/v2/test_volume_transfer_request.py
+++ b/openstackclient/tests/unit/volume/v2/test_volume_transfer_request.py
@@ -25,7 +25,6 @@ from openstackclient.volume.v2 import volume_transfer_request
class TestTransfer(volume_fakes.TestVolume):
-
def setUp(self):
super().setUp()
@@ -39,7 +38,6 @@ class TestTransfer(volume_fakes.TestVolume):
class TestTransferAccept(TestTransfer):
-
columns = (
'id',
'name',
@@ -61,11 +59,13 @@ class TestTransferAccept(TestTransfer):
# Get the command object to test
self.cmd = volume_transfer_request.AcceptTransferRequest(
- self.app, None)
+ self.app, None
+ )
def test_transfer_accept(self):
arglist = [
- '--auth-key', 'key_value',
+ '--auth-key',
+ 'key_value',
self.volume_transfer.id,
]
verifylist = [
@@ -104,7 +104,6 @@ class TestTransferAccept(TestTransfer):
class TestTransferCreate(TestTransfer):
-
volume = volume_fakes.create_one_volume()
columns = (
@@ -138,7 +137,8 @@ class TestTransferCreate(TestTransfer):
# Get the command object to test
self.cmd = volume_transfer_request.CreateTransferRequest(
- self.app, None)
+ self.app, None
+ )
def test_transfer_create_without_name(self):
arglist = [
@@ -151,14 +151,14 @@ class TestTransferCreate(TestTransfer):
columns, data = self.cmd.take_action(parsed_args)
- self.transfer_mock.create.assert_called_once_with(
- self.volume.id, None)
+ self.transfer_mock.create.assert_called_once_with(self.volume.id, None)
self.assertEqual(self.columns, columns)
self.assertEqual(self.data, data)
def test_transfer_create_with_name(self):
arglist = [
- '--name', self.volume_transfer.name,
+ '--name',
+ self.volume_transfer.name,
self.volume.id,
]
verifylist = [
@@ -170,13 +170,16 @@ class TestTransferCreate(TestTransfer):
columns, data = self.cmd.take_action(parsed_args)
self.transfer_mock.create.assert_called_once_with(
- self.volume.id, self.volume_transfer.name,)
+ self.volume.id,
+ self.volume_transfer.name,
+ )
self.assertEqual(self.columns, columns)
self.assertEqual(self.data, data)
def test_transfer_create_with_no_snapshots(self):
- self.app.client_manager.volume.api_version = \
- api_versions.APIVersion('3.55')
+ self.app.client_manager.volume.api_version = api_versions.APIVersion(
+ '3.55'
+ )
arglist = [
'--no-snapshots',
@@ -192,13 +195,15 @@ class TestTransferCreate(TestTransfer):
columns, data = self.cmd.take_action(parsed_args)
self.transfer_mock.create.assert_called_once_with(
- self.volume.id, None, no_snapshots=True)
+ self.volume.id, None, no_snapshots=True
+ )
self.assertEqual(self.columns, columns)
self.assertEqual(self.data, data)
def test_transfer_create_pre_v355(self):
- self.app.client_manager.volume.api_version = \
- api_versions.APIVersion('3.54')
+ self.app.client_manager.volume.api_version = api_versions.APIVersion(
+ '3.54'
+ )
arglist = [
'--no-snapshots',
@@ -212,16 +217,14 @@ class TestTransferCreate(TestTransfer):
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
exc = self.assertRaises(
- exceptions.CommandError,
- self.cmd.take_action,
- parsed_args)
+ exceptions.CommandError, self.cmd.take_action, parsed_args
+ )
self.assertIn(
- '--os-volume-api-version 3.55 or greater is required',
- str(exc))
+ '--os-volume-api-version 3.55 or greater is required', str(exc)
+ )
class TestTransferDelete(TestTransfer):
-
volume_transfers = volume_fakes.create_transfers(count=2)
def setUp(self):
@@ -234,21 +237,19 @@ class TestTransferDelete(TestTransfer):
# Get the command object to mock
self.cmd = volume_transfer_request.DeleteTransferRequest(
- self.app, None)
+ self.app, None
+ )
def test_transfer_delete(self):
- arglist = [
- self.volume_transfers[0].id
- ]
- verifylist = [
- ("transfer_request", [self.volume_transfers[0].id])
- ]
+ arglist = [self.volume_transfers[0].id]
+ verifylist = [("transfer_request", [self.volume_transfers[0].id])]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
result = self.cmd.take_action(parsed_args)
self.transfer_mock.delete.assert_called_with(
- self.volume_transfers[0].id)
+ self.volume_transfers[0].id
+ )
self.assertIsNone(result)
def test_delete_multiple_transfers(self):
@@ -280,17 +281,21 @@ class TestTransferDelete(TestTransfer):
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
find_mock_result = [self.volume_transfers[0], exceptions.CommandError]
- with mock.patch.object(utils, 'find_resource',
- side_effect=find_mock_result) as find_mock:
+ with mock.patch.object(
+ utils, 'find_resource', side_effect=find_mock_result
+ ) as find_mock:
try:
self.cmd.take_action(parsed_args)
self.fail('CommandError should be raised.')
except exceptions.CommandError as e:
- self.assertEqual('1 of 2 volume transfer requests failed '
- 'to delete', str(e))
+ self.assertEqual(
+ '1 of 2 volume transfer requests failed ' 'to delete',
+ str(e),
+ )
find_mock.assert_any_call(
- self.transfer_mock, self.volume_transfers[0].id)
+ self.transfer_mock, self.volume_transfers[0].id
+ )
find_mock.assert_any_call(self.transfer_mock, 'unexist_transfer')
self.assertEqual(2, find_mock.call_count)
@@ -300,7 +305,6 @@ class TestTransferDelete(TestTransfer):
class TestTransferList(TestTransfer):
-
# The Transfers to be listed
volume_transfers = volume_fakes.create_one_transfer()
@@ -331,28 +335,25 @@ class TestTransferList(TestTransfer):
# confirming if all expected columns are present in the result.
self.assertEqual(expected_columns, columns)
- datalist = ((
- self.volume_transfers.id,
- self.volume_transfers.name,
- self.volume_transfers.volume_id,
- ), )
+ datalist = (
+ (
+ self.volume_transfers.id,
+ self.volume_transfers.name,
+ self.volume_transfers.volume_id,
+ ),
+ )
# confirming if all expected values are present in the result.
self.assertEqual(datalist, tuple(data))
# checking if proper call was made to list volume_transfers
self.transfer_mock.list.assert_called_with(
- detailed=True,
- search_opts={'all_tenants': 0}
+ detailed=True, search_opts={'all_tenants': 0}
)
def test_transfer_list_with_argument(self):
- arglist = [
- "--all-projects"
- ]
- verifylist = [
- ("all_projects", True)
- ]
+ arglist = ["--all-projects"]
+ verifylist = [("all_projects", True)]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -370,24 +371,24 @@ class TestTransferList(TestTransfer):
# confirming if all expected columns are present in the result.
self.assertEqual(expected_columns, columns)
- datalist = ((
- self.volume_transfers.id,
- self.volume_transfers.name,
- self.volume_transfers.volume_id,
- ), )
+ datalist = (
+ (
+ self.volume_transfers.id,
+ self.volume_transfers.name,
+ self.volume_transfers.volume_id,
+ ),
+ )
# confirming if all expected values are present in the result.
self.assertEqual(datalist, tuple(data))
# checking if proper call was made to list volume_transfers
self.transfer_mock.list.assert_called_with(
- detailed=True,
- search_opts={'all_tenants': 1}
+ detailed=True, search_opts={'all_tenants': 1}
)
class TestTransferShow(TestTransfer):
-
columns = (
'created_at',
'id',
@@ -411,8 +412,7 @@ class TestTransferShow(TestTransfer):
self.transfer_mock.get.return_value = self.volume_transfer
# Get the command object to test
- self.cmd = volume_transfer_request.ShowTransferRequest(
- self.app, None)
+ self.cmd = volume_transfer_request.ShowTransferRequest(self.app, None)
def test_transfer_show(self):
arglist = [
@@ -425,7 +425,6 @@ class TestTransferShow(TestTransfer):
columns, data = self.cmd.take_action(parsed_args)
- self.transfer_mock.get.assert_called_once_with(
- self.volume_transfer.id)
+ self.transfer_mock.get.assert_called_once_with(self.volume_transfer.id)
self.assertEqual(self.columns, columns)
self.assertEqual(self.data, data)