add negative unit test for show deployable

add negative unit test for show not exist deployable

Change-Id: I95d39c70c4d1f3a47c34c70ca26413b101ea2148
This commit is contained in:
wangzhiguang 2023-07-03 11:30:40 +08:00
parent 63ebaa668d
commit 911defad33
1 changed files with 15 additions and 0 deletions

View File

@ -10,10 +10,14 @@
# License for the specific language governing permissions and limitations
# under the License.
#
import copy
from cyborgclient import exceptions as exc
from cyborgclient.osc.v2 import deployable as osc_deployable
from cyborgclient.tests.unit.osc.v2 import fakes as acc_fakes
from openstack import exceptions as sdk_exc
class TestDeployable(acc_fakes.TestAccelerator):
@ -133,3 +137,14 @@ class TestDeployableShow(TestDeployable):
acc_fakes.deployable_name
]
self.assertEqual(datalist, list(data))
def test_deployable_show_not_exist(self):
get_arq_req = self.mock_acc_client.get_deployable
get_arq_req.side_effect = sdk_exc.ResourceNotFound
arglist = [acc_fakes.deployable_uuid]
verifylist = []
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.assertRaisesRegex(
exc.CommandError,
'deployable not found: %s' % acc_fakes.deployable_uuid,
self.cmd.take_action, parsed_args)