add negative unit test for delete device profile

add negative unit test for delete not exist profile

Change-Id: I527c3d43e6ce60dff374c8183134b8d89ea1721e
This commit is contained in:
wangzhiguang 2023-07-03 15:20:26 +08:00
parent 63ebaa668d
commit f99ad1273a
2 changed files with 13 additions and 0 deletions

View File

@ -131,6 +131,8 @@ class DeleteDeviceProfile(command.Command):
try:
acc_client.delete_device_profile(uuid, False)
print(_('Deleted device_profile %s') % uuid)
except sdk_exc.ResourceNotFound:
raise exc.CommandError(_('device_profile %s not found') % uuid)
except exc.ClientException as e:
failures.append(_("Failed to delete device_profile \
%(device_profile)s: %(error)s")

View File

@ -207,3 +207,14 @@ class TestDeviceProfileDelete(TestDeviceProfile):
self.mock_acc_client.delete_device_profile.assert_called_with(
acc_fakes.device_profile_uuid, False)
def test_device_profile_delete_not_exist(self):
get_arq_req = self.mock_acc_client.delete_device_profile
get_arq_req.side_effect = sdk_exc.ResourceNotFound
arglist = [acc_fakes.device_profile_uuid]
verifylist = []
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.assertRaisesRegex(
exc.CommandError,
'device_profile %s not found' % acc_fakes.device_profile_uuid,
self.cmd.take_action, parsed_args)