Add device profiles test case for device_profile APIs

This case tests the device profile APIs, such as create/list/show/delete
device profile, this is a good way to verify the changes in device profiles
APIs.

Change-Id: If03832564fd5457797da3f4a5d6b9e2c6361611e
This commit is contained in:
zhangbailin 2021-04-07 18:46:59 +08:00
parent 68c4862b48
commit b19e2cfee1

View File

@ -36,41 +36,30 @@ class TestDeviceProfileController(base.BaseAPITest):
self.os_admin.cyborg_client.delete_multiple_device_profile_by_names(
dp_one[0]['name'], dp_two[0]['name'])
# TODO(brinzhang): After backport
# https://review.opendev.org/c/openstack/cyborg/+/784521, we will modify
# this test case.
def test_get_and_delete_device_profile(self):
dp = cyborg_data.NORMAL_DEVICE_PROFILE_DATA1
create_resp = self.os_admin.cyborg_client.create_device_profile(dp)
device_profile_uuid = create_resp['uuid']
self.assertEqual(dp[0]['name'], create_resp['name'])
self.assertEqual(dp[0]['groups'], create_resp['groups'])
# def test_get_and_delete_device_profile(self):
# # Removing the residual resources if it exists in the env
# list_resp = self.os_admin.cyborg_client.list_device_profile()
# if len(list_resp['device_profiles']) >= 1:
# self.os_admin.cyborg_client.delete_device_profile_by_uuid(
# list_resp['device_profiles'][0]['uuid'])
list_resp = self.os_admin.cyborg_client.list_device_profile()
device_profile_list = list_resp['device_profiles']
device_profile_uuid_list = [it['uuid'] for it in device_profile_list]
self.assertIn(device_profile_uuid, device_profile_uuid_list)
# dp = cyborg_data.NORMAL_DEVICE_PROFILE_DATA1
# create_resp = self.os_admin.cyborg_client.create_device_profile(dp)
# device_profile_uuid = create_resp['uuid']
# self.assertEqual(dp[0]['name'], create_resp['name'])
# self.assertEqual(dp[0]['groups'], create_resp['groups'])
get_resp = self.os_admin.cyborg_client.get_device_profile(
device_profile_uuid)
self.assertEqual(dp[0]['name'], get_resp['device_profile']['name'])
self.assertEqual(device_profile_uuid,
get_resp['device_profile']['uuid'])
# list_resp = self.os_admin.cyborg_client.list_device_profile()
# device_profile_list = list_resp['device_profiles']
# device_profile_uuid_list = [it['uuid'] for it in device_profile_list]
# self.assertIn(device_profile_uuid, device_profile_uuid_list)
# get_resp = self.os_admin.cyborg_client.get_device_profile(
# device_profile_uuid)
# self.assertEqual(dp[0]['name'], get_resp['name'])
# self.assertEqual(
# device_profile_uuid,
# get_resp['uuid'])
# self.os_admin.cyborg_client.delete_device_profile_by_uuid(
# device_profile_uuid)
# list_resp = self.os_admin.cyborg_client.list_device_profile()
# device_profile_list = list_resp['device_profiles']
# device_profile_uuid_list = [it['uuid'] for it in device_profile_list]
# self.assertNotIn(device_profile_uuid, device_profile_uuid_list)
self.os_admin.cyborg_client.delete_device_profile_by_uuid(
device_profile_uuid)
list_resp = self.os_admin.cyborg_client.list_device_profile()
device_profile_list = list_resp['device_profiles']
device_profile_uuid_list = [it['uuid'] for it in device_profile_list]
self.assertNotIn(device_profile_uuid, device_profile_uuid_list)
@classmethod
def resource_cleanup(cls):