Merge "add list devices filter by type"

This commit is contained in:
Zuul 2022-06-22 03:00:33 +00:00 committed by Gerrit Code Review
commit d76222b77b
2 changed files with 17 additions and 2 deletions

View File

@ -15,6 +15,7 @@
from oslo_log import log as logging
from oslo_serialization import jsonutils as json
from urllib import parse
from tempest import config
from tempest.lib import auth
@ -55,8 +56,11 @@ class CyborgRestClient(rest_client.RestClient):
resp, body = self.delete(url)
return self._response_helper(resp, body)
def list_devices(self):
resp, body = self.get("/devices")
def list_devices(self, params=None):
url = "/devices"
if params is not None:
url += '?%s' % parse.urlencode(params)
resp, body = self.get(url)
return self._response_helper(resp, body)
def get_device(self, device_uuid):

View File

@ -33,6 +33,17 @@ class TestDevice(base.BaseAPITest):
device_uuid)
self.assertEqual(device_uuid, response['uuid'])
def test_list_devices_filter_by_type(self):
response = self.os_admin.cyborg_client.list_devices()
type_name = response['devices'][0]['type']
# list devices filter by type
params = {"type": type_name}
response = self.os_admin.cyborg_client.list_devices(params=params)
self.assertNotEmpty(response['devices'])
for dv in response['devices']:
self.assertEqual(type_name, dv['type'])
@classmethod
def resource_cleanup(cls):
super(TestDevice, cls).resource_cleanup()