From 4e82421f00696b5b12547382189513f8b4775f76 Mon Sep 17 00:00:00 2001 From: Kyrylo Romanenko Date: Fri, 1 Jul 2016 14:56:59 +0000 Subject: [PATCH] Verify JSON response of driver commands Test JSON response output to console for commands: driver-list, driver-show, driver-properties. Change-Id: I2e9363b051a496de93516446d3ed3ff687a5db23 Partial-Bug: #1555680 --- .../tests/functional/test_json_response.py | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/ironicclient/tests/functional/test_json_response.py b/ironicclient/tests/functional/test_json_response.py index 215ed6412..aa0a4ba9d 100644 --- a/ironicclient/tests/functional/test_json_response.py +++ b/ironicclient/tests/functional/test_json_response.py @@ -161,3 +161,50 @@ class TestNodeJsonResponse(base.FunctionalTestBase): .format(self.node['uuid'], node_name), parse=False) self.assertTrue(_is_valid_json(response, self.node_schema)) + + +class TestDriverJsonResponse(base.FunctionalTestBase): + """Test JSON responses for driver commands.""" + + def test_driver_list_json(self): + """Test JSON response for drivers list.""" + schema = { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": {"type": "string"}, + "hosts": {"type": "string"}, + }} + } + response = self.ironic('driver-list', flags='--json', parse=False) + self.assertTrue(_is_valid_json(response, schema)) + + def test_driver_show_json(self): + """Test JSON response for driver show.""" + schema = { + "type": "object", + "properties": { + "name": {"type": "string"}, + "hosts": { + "type": "array", + "items": {"type": "string"}} + } + } + drivers_names = self.get_drivers_names() + for driver in drivers_names: + response = self.ironic('driver-show', flags='--json', + params='{0}'.format(driver), parse=False) + self.assertTrue(_is_valid_json(response, schema)) + + def test_driver_properties_json(self): + """Test JSON response for driver properties.""" + schema = { + "type": "object", + "additionalProperties": {"type": "string"} + } + drivers_names = self.get_drivers_names() + for driver in drivers_names: + response = self.ironic('driver-properties', flags='--json', + params='{0}'.format(driver), parse=False) + self.assertTrue(_is_valid_json(response, schema))