commit 27fe28b7bd6729ad6b26a6b5b3beae82bc4037ce Author: wangzhiguang Date: Thu Sep 3 10:00:36 2020 +0800 Add cyborg get and delete device profile api tests Add get and/or delete device profile by uuid api tests Change-Id: I1dcaf76978762eec6cf4937c3006973a71b6cfbe diff --git a/cyborg_tempest_plugin/services/cyborg_rest_client.py b/cyborg_tempest_plugin/services/cyborg_rest_client.py index 0450ad4..3c76866 100644 --- a/cyborg_tempest_plugin/services/cyborg_rest_client.py +++ b/cyborg_tempest_plugin/services/cyborg_rest_client.py @@ -58,6 +58,16 @@ class CyborgRestClient(rest_client.RestClient): resp, body = self.get("/devices") return self._response_helper(resp, body) + def get_device_profile(self, device_profile_uuid): + url = self.DP_URL + "/" + device_profile_uuid + resp, body = self.get(url) + return self._response_helper(resp, body) + + def delete_device_profile_by_uuid(self, device_profile_uuid): + url = self.DP_URL + "/" + device_profile_uuid + resp, body = self.delete(url) + return self._response_helper(resp, body) + def get_auth_provider(credentials, scope='project'): default_params = { diff --git a/cyborg_tempest_plugin/tests/api/test_device_profile.py b/cyborg_tempest_plugin/tests/api/test_device_profile.py index 57ea247..5757902 100644 --- a/cyborg_tempest_plugin/tests/api/test_device_profile.py +++ b/cyborg_tempest_plugin/tests/api/test_device_profile.py @@ -52,6 +52,41 @@ class TestDeviceProfileController(base.BaseAPITest): self.os_admin.cyborg_client.delete_multiple_device_profile_by_names( dp_one[0]['name'], dp_two[0]['name']) + def test_get_and_delete_device_profile(self): + dp = [{ + "name": "afaas_example_2", + "groups": [ + {"resources:FPGA": "1", + "trait:CUSTOM_FPGA_1": "required", + "trait:CUSTOM_FUNCTION_ID_3AFB": "required", + } + ] + }] + + response = self.os_admin.cyborg_client.create_device_profile(dp) + device_profile_uuid = response['uuid'] + self.assertEqual(dp[0]['name'], response['name']) + self.assertEqual(dp[0]['groups'], response['groups']) + + response = self.os_admin.cyborg_client.list_device_profile() + device_profile_list = response['device_profiles'] + device_profile_uuid_list = [it['uuid'] for it in device_profile_list] + self.assertIn(device_profile_uuid, device_profile_uuid_list) + + response = self.os_admin.cyborg_client.get_device_profile( + device_profile_uuid) + self.assertEqual(dp[0]['name'], response['name']) + self.assertEqual( + device_profile_uuid, + response['uuid']) + + self.os_admin.cyborg_client.delete_device_profile_by_uuid( + device_profile_uuid) + response = self.os_admin.cyborg_client.list_device_profile() + device_profile_list = response['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): super(TestDeviceProfileController, cls).resource_cleanup()