Merge "Add checks for showing dp with name"

This commit is contained in:
Zuul
2021-08-23 10:37:25 +00:00
committed by Gerrit Code Review
2 changed files with 23 additions and 0 deletions

View File

@@ -20,6 +20,7 @@ from openstack import exceptions as sdk_exc
from osc_lib.command import command
from osc_lib import utils as oscutils
from oslo_serialization import jsonutils
from oslo_utils import uuidutils
from cyborgclient.common import utils
from cyborgclient import exceptions as exc
@@ -166,6 +167,10 @@ class ShowDeviceProfile(command.ShowOne):
def _show_device_profile(acc_client, uuid):
"""Show detailed info about device_profile."""
if not uuidutils.is_uuid_like(uuid):
raise exc.CommandError(_('Only UUID of device_profile allowed. '
'Invalid input: %s') % uuid)
columns = (
"created_at",
"updated_at",

View File

@@ -12,6 +12,7 @@
#
import copy
from cyborgclient import exceptions as exc
from cyborgclient.osc.v2 import device_profile as osc_device_profile
from cyborgclient.tests.unit.osc.v2 import fakes as acc_fakes
@@ -88,3 +89,20 @@ class TestDeviceProfileList(TestDeviceProfile):
acc_fakes.device_profile_groups,
), ]
self.assertEqual(datalist, list(data))
class TestDeviceProfileShow(TestDeviceProfile):
def setUp(self):
super(TestDeviceProfileShow, self).setUp()
self.cmd = osc_device_profile.ShowDeviceProfile(self.app, None)
def test_device_profile_show_with_name(self):
arg_list = [acc_fakes.device_profile_name]
verify_list = []
parsed_args = self.check_parser(self.cmd, arg_list, verify_list)
result = self.assertRaises(exc.CommandError,
self.cmd.take_action,
parsed_args)
self.assertIn("Only UUID of device_profile allowed. "
"Invalid input: fake_devprof_name", str(result))