[Volume] Check return value is None in volume unit tests
take_action() in commands inheriting from Command returns nothing. So we should assert the return is None in the unit tests of these commands. Change-Id: Idd961a5fa3db825353700837a559621d17f782c5 Partial-Bug: #1550636
This commit is contained in:
		| @@ -62,11 +62,13 @@ class TestQosAssociate(TestQos): | ||||
|         ] | ||||
|         parsed_args = self.check_parser(self.cmd, arglist, verifylist) | ||||
|  | ||||
|         self.cmd.take_action(parsed_args) | ||||
|         result = self.cmd.take_action(parsed_args) | ||||
|  | ||||
|         self.qos_mock.associate.assert_called_with( | ||||
|             volume_fakes.qos_id, | ||||
|             volume_fakes.type_id | ||||
|         ) | ||||
|         self.assertIsNone(result) | ||||
|  | ||||
|  | ||||
| class TestQosCreate(TestQos): | ||||
| @@ -204,11 +206,12 @@ class TestQosDelete(TestQos): | ||||
|         verifylist = [ | ||||
|             ('qos_specs', [volume_fakes.qos_id]) | ||||
|         ] | ||||
|  | ||||
|         parsed_args = self.check_parser(self.cmd, arglist, verifylist) | ||||
|  | ||||
|         self.cmd.take_action(parsed_args) | ||||
|         result = self.cmd.take_action(parsed_args) | ||||
|  | ||||
|         self.qos_mock.delete.assert_called_with(volume_fakes.qos_id) | ||||
|         self.assertIsNone(result) | ||||
|  | ||||
|     def test_qos_delete_with_name(self): | ||||
|         arglist = [ | ||||
| @@ -217,11 +220,12 @@ class TestQosDelete(TestQos): | ||||
|         verifylist = [ | ||||
|             ('qos_specs', [volume_fakes.qos_name]) | ||||
|         ] | ||||
|  | ||||
|         parsed_args = self.check_parser(self.cmd, arglist, verifylist) | ||||
|  | ||||
|         self.cmd.take_action(parsed_args) | ||||
|         result = self.cmd.take_action(parsed_args) | ||||
|  | ||||
|         self.qos_mock.delete.assert_called_with(volume_fakes.qos_id) | ||||
|         self.assertIsNone(result) | ||||
|  | ||||
|  | ||||
| class TestQosDisassociate(TestQos): | ||||
| @@ -253,11 +257,13 @@ class TestQosDisassociate(TestQos): | ||||
|         ] | ||||
|         parsed_args = self.check_parser(self.cmd, arglist, verifylist) | ||||
|  | ||||
|         self.cmd.take_action(parsed_args) | ||||
|         result = self.cmd.take_action(parsed_args) | ||||
|  | ||||
|         self.qos_mock.disassociate.assert_called_with( | ||||
|             volume_fakes.qos_id, | ||||
|             volume_fakes.type_id | ||||
|         ) | ||||
|         self.assertIsNone(result) | ||||
|  | ||||
|     def test_qos_disassociate_with_all_volume_types(self): | ||||
|         self.qos_mock.get.return_value = fakes.FakeResource( | ||||
| @@ -275,8 +281,10 @@ class TestQosDisassociate(TestQos): | ||||
|         ] | ||||
|         parsed_args = self.check_parser(self.cmd, arglist, verifylist) | ||||
|  | ||||
|         self.cmd.take_action(parsed_args) | ||||
|         result = self.cmd.take_action(parsed_args) | ||||
|  | ||||
|         self.qos_mock.disassociate_all.assert_called_with(volume_fakes.qos_id) | ||||
|         self.assertIsNone(result) | ||||
|  | ||||
|  | ||||
| class TestQosList(TestQos): | ||||
| @@ -351,11 +359,13 @@ class TestQosSet(TestQos): | ||||
|         ] | ||||
|         parsed_args = self.check_parser(self.cmd, arglist, verifylist) | ||||
|  | ||||
|         self.cmd.take_action(parsed_args) | ||||
|         result = self.cmd.take_action(parsed_args) | ||||
|  | ||||
|         self.qos_mock.set_keys.assert_called_with( | ||||
|             volume_fakes.qos_id, | ||||
|             volume_fakes.qos_specs | ||||
|         ) | ||||
|         self.assertIsNone(result) | ||||
|  | ||||
|  | ||||
| class TestQosShow(TestQos): | ||||
| @@ -436,8 +446,10 @@ class TestQosUnset(TestQos): | ||||
|         ] | ||||
|         parsed_args = self.check_parser(self.cmd, arglist, verifylist) | ||||
|  | ||||
|         self.cmd.take_action(parsed_args) | ||||
|         result = self.cmd.take_action(parsed_args) | ||||
|  | ||||
|         self.qos_mock.unset_keys.assert_called_with( | ||||
|             volume_fakes.qos_id, | ||||
|             ['iops', 'foo'] | ||||
|         ) | ||||
|         self.assertIsNone(result) | ||||
|   | ||||
| @@ -578,6 +578,7 @@ class TestVolumeSet(TestVolume): | ||||
|         parsed_args = self.check_parser(self.cmd, arglist, verifylist) | ||||
|  | ||||
|         result = self.cmd.run(parsed_args) | ||||
|  | ||||
|         self.assertEqual(0, result) | ||||
|         self.assertEqual("No changes requested\n", | ||||
|                          self.app.log.messages.get('error')) | ||||
| @@ -596,7 +597,7 @@ class TestVolumeSet(TestVolume): | ||||
|         ] | ||||
|         parsed_args = self.check_parser(self.cmd, arglist, verifylist) | ||||
|  | ||||
|         self.cmd.take_action(parsed_args) | ||||
|         result = self.cmd.take_action(parsed_args) | ||||
|  | ||||
|         # Set expected values | ||||
|         kwargs = { | ||||
| @@ -606,6 +607,7 @@ class TestVolumeSet(TestVolume): | ||||
|             volume_fakes.volume_id, | ||||
|             **kwargs | ||||
|         ) | ||||
|         self.assertIsNone(result) | ||||
|  | ||||
|     def test_volume_set_description(self): | ||||
|         arglist = [ | ||||
| @@ -621,7 +623,7 @@ class TestVolumeSet(TestVolume): | ||||
|         ] | ||||
|         parsed_args = self.check_parser(self.cmd, arglist, verifylist) | ||||
|  | ||||
|         self.cmd.take_action(parsed_args) | ||||
|         result = self.cmd.take_action(parsed_args) | ||||
|  | ||||
|         # Set expected values | ||||
|         kwargs = { | ||||
| @@ -631,6 +633,7 @@ class TestVolumeSet(TestVolume): | ||||
|             volume_fakes.volume_id, | ||||
|             **kwargs | ||||
|         ) | ||||
|         self.assertIsNone(result) | ||||
|  | ||||
|     def test_volume_set_size(self): | ||||
|         arglist = [ | ||||
| @@ -646,15 +649,15 @@ class TestVolumeSet(TestVolume): | ||||
|         ] | ||||
|         parsed_args = self.check_parser(self.cmd, arglist, verifylist) | ||||
|  | ||||
|         self.cmd.take_action(parsed_args) | ||||
|         result = self.cmd.take_action(parsed_args) | ||||
|  | ||||
|         # Set expected values | ||||
|         size = 130 | ||||
|  | ||||
|         self.volumes_mock.extend.assert_called_with( | ||||
|             volume_fakes.volume_id, | ||||
|             size | ||||
|         ) | ||||
|         self.assertIsNone(result) | ||||
|  | ||||
|     def test_volume_set_size_smaller(self): | ||||
|         arglist = [ | ||||
| @@ -671,6 +674,7 @@ class TestVolumeSet(TestVolume): | ||||
|         parsed_args = self.check_parser(self.cmd, arglist, verifylist) | ||||
|  | ||||
|         result = self.cmd.run(parsed_args) | ||||
|  | ||||
|         self.assertEqual(0, result) | ||||
|         self.assertEqual("New size must be greater than %s GB" % | ||||
|                          volume_fakes.volume_size, | ||||
| @@ -692,6 +696,7 @@ class TestVolumeSet(TestVolume): | ||||
|         parsed_args = self.check_parser(self.cmd, arglist, verifylist) | ||||
|  | ||||
|         result = self.cmd.run(parsed_args) | ||||
|  | ||||
|         self.assertEqual(0, result) | ||||
|         self.assertEqual("Volume is in %s state, it must be available before " | ||||
|                          "size can be extended" % 'error', | ||||
| @@ -711,7 +716,7 @@ class TestVolumeSet(TestVolume): | ||||
|         ] | ||||
|         parsed_args = self.check_parser(self.cmd, arglist, verifylist) | ||||
|  | ||||
|         self.cmd.take_action(parsed_args) | ||||
|         result = self.cmd.take_action(parsed_args) | ||||
|  | ||||
|         # Set expected values | ||||
|         metadata = { | ||||
| @@ -721,3 +726,4 @@ class TestVolumeSet(TestVolume): | ||||
|             volume_fakes.volume_id, | ||||
|             metadata | ||||
|         ) | ||||
|         self.assertIsNone(result) | ||||
|   | ||||
| @@ -99,11 +99,12 @@ class TestBackupDelete(TestBackup): | ||||
|         verifylist = [ | ||||
|             ("backups", [volume_fakes.backup_id]) | ||||
|         ] | ||||
|  | ||||
|         parsed_args = self.check_parser(self.cmd, arglist, verifylist) | ||||
|  | ||||
|         self.cmd.take_action(parsed_args) | ||||
|         result = self.cmd.take_action(parsed_args) | ||||
|  | ||||
|         self.backups_mock.delete.assert_called_with(volume_fakes.backup_id) | ||||
|         self.assertIsNone(result) | ||||
|  | ||||
|  | ||||
| class TestBackupList(TestBackup): | ||||
| @@ -213,9 +214,10 @@ class TestBackupRestore(TestBackup): | ||||
|         ] | ||||
|         parsed_args = self.check_parser(self.cmd, arglist, verifylist) | ||||
|  | ||||
|         self.cmd.take_action(parsed_args) | ||||
|         result = self.cmd.take_action(parsed_args) | ||||
|         self.restores_mock.restore.assert_called_with(volume_fakes.backup_id, | ||||
|                                                       volume_fakes.volume_id) | ||||
|         self.assertIsNone(result) | ||||
|  | ||||
|  | ||||
| class TestBackupShow(TestBackup): | ||||
|   | ||||
| @@ -62,11 +62,13 @@ class TestQosAssociate(TestQos): | ||||
|         ] | ||||
|         parsed_args = self.check_parser(self.cmd, arglist, verifylist) | ||||
|  | ||||
|         self.cmd.take_action(parsed_args) | ||||
|         result = self.cmd.take_action(parsed_args) | ||||
|  | ||||
|         self.qos_mock.associate.assert_called_with( | ||||
|             volume_fakes.qos_id, | ||||
|             volume_fakes.type_id | ||||
|         ) | ||||
|         self.assertIsNone(result) | ||||
|  | ||||
|  | ||||
| class TestQosCreate(TestQos): | ||||
| @@ -205,11 +207,12 @@ class TestQosDelete(TestQos): | ||||
|         verifylist = [ | ||||
|             ('qos_specs', [volume_fakes.qos_id]) | ||||
|         ] | ||||
|  | ||||
|         parsed_args = self.check_parser(self.cmd, arglist, verifylist) | ||||
|  | ||||
|         self.cmd.take_action(parsed_args) | ||||
|         result = self.cmd.take_action(parsed_args) | ||||
|  | ||||
|         self.qos_mock.delete.assert_called_with(volume_fakes.qos_id) | ||||
|         self.assertIsNone(result) | ||||
|  | ||||
|     def test_qos_delete_with_name(self): | ||||
|         arglist = [ | ||||
| @@ -218,11 +221,12 @@ class TestQosDelete(TestQos): | ||||
|         verifylist = [ | ||||
|             ('qos_specs', [volume_fakes.qos_name]) | ||||
|         ] | ||||
|  | ||||
|         parsed_args = self.check_parser(self.cmd, arglist, verifylist) | ||||
|  | ||||
|         self.cmd.take_action(parsed_args) | ||||
|         result = self.cmd.take_action(parsed_args) | ||||
|  | ||||
|         self.qos_mock.delete.assert_called_with(volume_fakes.qos_id) | ||||
|         self.assertIsNone(result) | ||||
|  | ||||
|  | ||||
| class TestQosDisassociate(TestQos): | ||||
| @@ -254,11 +258,13 @@ class TestQosDisassociate(TestQos): | ||||
|         ] | ||||
|         parsed_args = self.check_parser(self.cmd, arglist, verifylist) | ||||
|  | ||||
|         self.cmd.take_action(parsed_args) | ||||
|         result = self.cmd.take_action(parsed_args) | ||||
|  | ||||
|         self.qos_mock.disassociate.assert_called_with( | ||||
|             volume_fakes.qos_id, | ||||
|             volume_fakes.type_id | ||||
|         ) | ||||
|         self.assertIsNone(result) | ||||
|  | ||||
|     def test_qos_disassociate_with_all_volume_types(self): | ||||
|         self.qos_mock.get.return_value = fakes.FakeResource( | ||||
| @@ -276,8 +282,10 @@ class TestQosDisassociate(TestQos): | ||||
|         ] | ||||
|         parsed_args = self.check_parser(self.cmd, arglist, verifylist) | ||||
|  | ||||
|         self.cmd.take_action(parsed_args) | ||||
|         result = self.cmd.take_action(parsed_args) | ||||
|  | ||||
|         self.qos_mock.disassociate_all.assert_called_with(volume_fakes.qos_id) | ||||
|         self.assertIsNone(result) | ||||
|  | ||||
|  | ||||
| class TestQosList(TestQos): | ||||
| @@ -352,11 +360,13 @@ class TestQosSet(TestQos): | ||||
|         ] | ||||
|         parsed_args = self.check_parser(self.cmd, arglist, verifylist) | ||||
|  | ||||
|         self.cmd.take_action(parsed_args) | ||||
|         result = self.cmd.take_action(parsed_args) | ||||
|  | ||||
|         self.qos_mock.set_keys.assert_called_with( | ||||
|             volume_fakes.qos_id, | ||||
|             volume_fakes.qos_specs | ||||
|         ) | ||||
|         self.assertIsNone(result) | ||||
|  | ||||
|  | ||||
| class TestQosShow(TestQos): | ||||
| @@ -430,15 +440,16 @@ class TestQosUnset(TestQos): | ||||
|             '--property', 'iops', | ||||
|             '--property', 'foo' | ||||
|         ] | ||||
|  | ||||
|         verifylist = [ | ||||
|             ('qos_spec', volume_fakes.qos_id), | ||||
|             ('property', ['iops', 'foo']) | ||||
|         ] | ||||
|         parsed_args = self.check_parser(self.cmd, arglist, verifylist) | ||||
|  | ||||
|         self.cmd.take_action(parsed_args) | ||||
|         result = self.cmd.take_action(parsed_args) | ||||
|  | ||||
|         self.qos_mock.unset_keys.assert_called_with( | ||||
|             volume_fakes.qos_id, | ||||
|             ['iops', 'foo'] | ||||
|         ) | ||||
|         self.assertIsNone(result) | ||||
|   | ||||
| @@ -97,11 +97,12 @@ class TestSnapshotDelete(TestSnapshot): | ||||
|         verifylist = [ | ||||
|             ("snapshots", [volume_fakes.snapshot_id]) | ||||
|         ] | ||||
|  | ||||
|         parsed_args = self.check_parser(self.cmd, arglist, verifylist) | ||||
|  | ||||
|         self.cmd.take_action(parsed_args) | ||||
|         result = self.cmd.take_action(parsed_args) | ||||
|  | ||||
|         self.snapshots_mock.delete.assert_called_with(volume_fakes.snapshot_id) | ||||
|         self.assertIsNone(result) | ||||
|  | ||||
|  | ||||
| class TestSnapshotList(TestSnapshot): | ||||
| @@ -231,18 +232,19 @@ class TestSnapshotSet(TestSnapshot): | ||||
|             ("name", "new_snapshot"), | ||||
|             ("property", new_property) | ||||
|         ] | ||||
|         parsed_args = self.check_parser(self.cmd, arglist, verifylist) | ||||
|  | ||||
|         result = self.cmd.take_action(parsed_args) | ||||
|  | ||||
|         kwargs = { | ||||
|             "name": "new_snapshot", | ||||
|         } | ||||
|         parsed_args = self.check_parser(self.cmd, arglist, verifylist) | ||||
|         self.cmd.take_action(parsed_args) | ||||
|  | ||||
|         self.snapshots_mock.update.assert_called_with( | ||||
|             volume_fakes.snapshot_id, **kwargs) | ||||
|         self.snapshots_mock.set_metadata.assert_called_with( | ||||
|             volume_fakes.snapshot_id, new_property | ||||
|         ) | ||||
|         self.assertIsNone(result) | ||||
|  | ||||
|  | ||||
| class TestSnapshotShow(TestSnapshot): | ||||
| @@ -296,10 +298,11 @@ class TestSnapshotUnset(TestSnapshot): | ||||
|             ("snapshot", volume_fakes.snapshot_id), | ||||
|             ("property", ["foo"]) | ||||
|         ] | ||||
|  | ||||
|         parsed_args = self.check_parser(self.cmd, arglist, verifylist) | ||||
|         self.cmd.take_action(parsed_args) | ||||
|  | ||||
|         result = self.cmd.take_action(parsed_args) | ||||
|  | ||||
|         self.snapshots_mock.delete_metadata.assert_called_with( | ||||
|             volume_fakes.snapshot_id, ["foo"] | ||||
|         ) | ||||
|         self.assertIsNone(result) | ||||
|   | ||||
| @@ -137,11 +137,12 @@ class TestTypeDelete(TestType): | ||||
|         verifylist = [ | ||||
|             ("volume_type", volume_fakes.type_id) | ||||
|         ] | ||||
|  | ||||
|         parsed_args = self.check_parser(self.cmd, arglist, verifylist) | ||||
|  | ||||
|         self.cmd.take_action(parsed_args) | ||||
|         result = self.cmd.take_action(parsed_args) | ||||
|  | ||||
|         self.types_mock.delete.assert_called_with(volume_fakes.type_id) | ||||
|         self.assertIsNone(result) | ||||
|  | ||||
|  | ||||
| class TestTypeList(TestType): | ||||
| @@ -227,7 +228,7 @@ class TestTypeSet(TestType): | ||||
|         ] | ||||
|         parsed_args = self.check_parser(self.cmd, arglist, verifylist) | ||||
|  | ||||
|         self.cmd.take_action(parsed_args) | ||||
|         result = self.cmd.take_action(parsed_args) | ||||
|  | ||||
|         # Set expected values | ||||
|         kwargs = { | ||||
| @@ -237,6 +238,7 @@ class TestTypeSet(TestType): | ||||
|             volume_fakes.type_id, | ||||
|             **kwargs | ||||
|         ) | ||||
|         self.assertIsNone(result) | ||||
|  | ||||
|     def test_type_set_description(self): | ||||
|         new_desc = 'new_desc' | ||||
| @@ -252,7 +254,7 @@ class TestTypeSet(TestType): | ||||
|         ] | ||||
|         parsed_args = self.check_parser(self.cmd, arglist, verifylist) | ||||
|  | ||||
|         self.cmd.take_action(parsed_args) | ||||
|         result = self.cmd.take_action(parsed_args) | ||||
|  | ||||
|         # Set expected values | ||||
|         kwargs = { | ||||
| @@ -262,6 +264,7 @@ class TestTypeSet(TestType): | ||||
|             volume_fakes.type_id, | ||||
|             **kwargs | ||||
|         ) | ||||
|         self.assertIsNone(result) | ||||
|  | ||||
|     def test_type_set_property(self): | ||||
|         arglist = [ | ||||
| @@ -276,7 +279,8 @@ class TestTypeSet(TestType): | ||||
|         ] | ||||
|         parsed_args = self.check_parser(self.cmd, arglist, verifylist) | ||||
|  | ||||
|         self.cmd.take_action(parsed_args) | ||||
|         result = self.cmd.take_action(parsed_args) | ||||
|         self.assertIsNone(result) | ||||
|  | ||||
|         result = self.types_mock.get.return_value._keys | ||||
|         self.assertIn('myprop', result) | ||||
| @@ -338,8 +342,8 @@ class TestTypeUnset(TestType): | ||||
|  | ||||
|         parsed_args = self.check_parser(self.cmd, arglist, verifylist) | ||||
|  | ||||
|         self.cmd.take_action(parsed_args) | ||||
|         result = self.cmd.take_action(parsed_args) | ||||
|         self.assertIsNone(result) | ||||
|  | ||||
|         result = self.types_mock.get.return_value._keys | ||||
|  | ||||
|         self.assertNotIn('property', result) | ||||
|   | ||||
| @@ -396,11 +396,12 @@ class TestVolumeDelete(TestVolume): | ||||
|         verifylist = [ | ||||
|             ("volumes", [volumes[0].id]) | ||||
|         ] | ||||
|  | ||||
|         parsed_args = self.check_parser(self.cmd, arglist, verifylist) | ||||
|  | ||||
|         self.cmd.take_action(parsed_args) | ||||
|         result = self.cmd.take_action(parsed_args) | ||||
|  | ||||
|         self.volumes_mock.delete.assert_called_with(volumes[0].id) | ||||
|         self.assertIsNone(result) | ||||
|  | ||||
|     def test_volume_delete_multi_volumes(self): | ||||
|         volumes = self.setup_volumes_mock(count=3) | ||||
| @@ -409,14 +410,13 @@ class TestVolumeDelete(TestVolume): | ||||
|         verifylist = [ | ||||
|             ('volumes', arglist), | ||||
|         ] | ||||
|  | ||||
|         parsed_args = self.check_parser(self.cmd, arglist, verifylist) | ||||
|  | ||||
|         self.cmd.take_action(parsed_args) | ||||
|         result = self.cmd.take_action(parsed_args) | ||||
|  | ||||
|         calls = [call(v.id) for v in volumes] | ||||
|  | ||||
|         self.volumes_mock.delete.assert_has_calls(calls) | ||||
|         self.assertIsNone(result) | ||||
|  | ||||
|  | ||||
| class TestVolumeList(TestVolume): | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Tang Chen
					Tang Chen