Merge "Add the negative test for create dp with the same name"

This commit is contained in:
Zuul 2020-12-23 11:58:34 +00:00 committed by Gerrit Code Review
commit 1911100272

View File

@ -40,3 +40,25 @@ class DeviceProfileNegativeTest(base.BaseAPITest):
lib_exc.NotFound,
self.os_admin.cyborg_client.delete_device_profile_by_uuid,
non_existent_id)
@test.attr(type=['negative', 'gate'])
def test_create_device_profile_server_fault(self):
# create device profile name same
dp = [{
"name": "fpga_same_test",
"groups": [
{
"resources:FPGA": "1",
"trait:CUSTOM_FAKE_DEVICE": "required"
}]
}]
# create a device profile with named "fpga_same_test"
response = self.os_admin.cyborg_client.create_device_profile(dp)
self.assertEqual(dp[0]['name'], response['name'])
self.addCleanup(self.os_admin.cyborg_client.delete_device_profile,
dp[0]['name'])
# create a same device profile with the same name "fpga_same_test"
self.assertRaises(lib_exc.ServerFault,
self.os_admin.cyborg_client.create_device_profile,
dp)