summaryrefslogtreecommitdiff
path: root/ironic
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-12-03 23:55:40 +0000
committerGerrit Code Review <review@openstack.org>2013-12-03 23:55:40 +0000
commiteac4fab8a50a3754f7727cfeecd4061829246cba (patch)
tree49eb9ba1202958db2aed6d85eee47e1f04db5a57 /ironic
parent1d861582167758caa03212a5475ab2c2407882f2 (diff)
parent04b7051a34d346c248452b269b55fa4875093fc2 (diff)
downloadironic-eac4fab8a50a3754f7727cfeecd4061829246cba.tar.gz
Merge "Add missing link for drivers resource"
Diffstat (limited to 'ironic')
-rw-r--r--ironic/api/controllers/v1/__init__.py10
-rw-r--r--ironic/tests/api/test_root.py11
2 files changed, 18 insertions, 3 deletions
diff --git a/ironic/api/controllers/v1/__init__.py b/ironic/api/controllers/v1/__init__.py
index 8ed29f742..6e3148f55 100644
--- a/ironic/api/controllers/v1/__init__.py
+++ b/ironic/api/controllers/v1/__init__.py
@@ -70,6 +70,9 @@ class V1(base.APIBase):
ports = [link.Link]
"Links to the ports resource"
+ drivers = [link.Link]
+ "Links to the drivers resource"
+
@classmethod
def convert(self):
v1 = V1()
@@ -105,6 +108,13 @@ class V1(base.APIBase):
'ports', '',
bookmark=True)
]
+ v1.drivers = [link.Link.make_link('self', pecan.request.host_url,
+ 'drivers', ''),
+ link.Link.make_link('bookmark',
+ pecan.request.host_url,
+ 'drivers', '',
+ bookmark=True)
+ ]
return v1
diff --git a/ironic/tests/api/test_root.py b/ironic/tests/api/test_root.py
index 37742ea15..395401fab 100644
--- a/ironic/tests/api/test_root.py
+++ b/ironic/tests/api/test_root.py
@@ -34,8 +34,13 @@ class TestV1Root(base.FunctionalTest):
data = self.get_json('/')
self.assertEqual(data['id'], 'v1')
# Check fields are not empty
- [self.assertNotIn(f, ['', []]) for f in data.keys()]
- # Check if the resources are present
- [self.assertIn(r, data.keys()) for r in ('chassis', 'nodes', 'ports')]
+ for f in data.keys():
+ self.assertNotIn(f, ['', []])
+ # Check if all known resources are present and there are no extra ones.
+ not_resources = ('id', 'links', 'media_types')
+ actual_resources = tuple(set(data.keys()) - set(not_resources))
+ expected_resources = ('chassis', 'drivers', 'nodes', 'ports')
+ self.assertEqual(sorted(expected_resources), sorted(actual_resources))
+
self.assertIn({'type': 'application/vnd.openstack.ironic.v1+json',
'base': 'application/json'}, data['media_types'])