summaryrefslogtreecommitdiff
path: root/ironic/tests/unit/api
diff options
context:
space:
mode:
authorMark Goddard <mark@stackhpc.com>2018-01-23 12:06:49 +0000
committerJim Rollenhagen <jim@jimrollenhagen.com>2018-01-30 10:01:26 -0500
commitccf22acb53f4357047e4e0caa658bf9801d817c4 (patch)
treebcb368827c19b2381c62760f7c6a47e38cb93d77 /ironic/tests/unit/api
parentc9677cd43ba61e737d91294b94e7ed74c282dca5 (diff)
downloadironic-ccf22acb53f4357047e4e0caa658bf9801d817c4.tar.gz
Fix nits found in node traits
Includes: * Return a location in HTTP response header for PUT /nodes/<node>/traits/<trait>. * Correct order of arguments to assertEqual() in conductor manager unit tests for traits. * Use () rather than \ for multiline formatting. * Set tags and traits fields on NodeModel to default of [] in DB node create after DB insert. Change-Id: Ia88f7ca69b777b82caca2871e44edab39f2a8310 Partial-Bug: #1722194
Diffstat (limited to 'ironic/tests/unit/api')
-rw-r--r--ironic/tests/unit/api/controllers/v1/test_node.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/ironic/tests/unit/api/controllers/v1/test_node.py b/ironic/tests/unit/api/controllers/v1/test_node.py
index 6fcc8240e..2b2102817 100644
--- a/ironic/tests/unit/api/controllers/v1/test_node.py
+++ b/ironic/tests/unit/api/controllers/v1/test_node.py
@@ -4363,6 +4363,7 @@ class TestTraits(test_api_base.BaseApiTest):
notify_args = mock_notify.call_args_list
self.assertEqual(traits, notify_args[0][0][1].traits.get_trait_names())
self.assertEqual(traits, notify_args[1][0][1].traits.get_trait_names())
+ self.assertIsNone(ret.location)
@mock.patch.object(rpcapi.ConductorAPI, 'add_node_traits')
@mock.patch.object(notification_utils, '_emit_api_notification')
@@ -4391,6 +4392,7 @@ class TestTraits(test_api_base.BaseApiTest):
notify_args = mock_notify.call_args_list
self.assertEqual(traits, notify_args[0][0][1].traits.get_trait_names())
self.assertEqual(traits, notify_args[1][0][1].traits.get_trait_names())
+ self.assertIsNone(ret.location)
@mock.patch.object(rpcapi.ConductorAPI, 'add_node_traits')
@mock.patch.object(notification_utils, '_emit_api_notification')
@@ -4414,6 +4416,7 @@ class TestTraits(test_api_base.BaseApiTest):
notify_args = mock_notify.call_args_list
self.assertEqual([], notify_args[0][0][1].traits.get_trait_names())
self.assertEqual([], notify_args[1][0][1].traits.get_trait_names())
+ self.assertIsNone(ret.location)
@mock.patch.object(rpcapi.ConductorAPI, 'add_node_traits')
@mock.patch.object(notification_utils, '_emit_api_notification')
@@ -4480,6 +4483,11 @@ class TestTraits(test_api_base.BaseApiTest):
notify_args = mock_notify.call_args_list
self.assertEqual(traits, notify_args[0][0][1].traits.get_trait_names())
self.assertEqual(traits, notify_args[1][0][1].traits.get_trait_names())
+ # Check location header.
+ self.assertIsNotNone(ret.location)
+ expected_location = '/v1/nodes/%s/traits/CUSTOM_3' % self.node.name
+ self.assertEqual(expected_location,
+ urlparse.urlparse(ret.location).path)
@mock.patch.object(rpcapi.ConductorAPI, 'add_node_traits')
@mock.patch.object(notification_utils, '_emit_api_notification')
@@ -4606,7 +4614,7 @@ class TestTraits(test_api_base.BaseApiTest):
self.assertEqual(traits, notify_args[0][0][1].traits.get_trait_names())
self.assertEqual(traits, notify_args[1][0][1].traits.get_trait_names())
- def test_add_single_traits_fails_with_bad_version(self):
+ def test_add_single_trait_fails_with_bad_version(self):
ret = self.put_json('/nodes/%s/traits/CUSTOM_TRAIT1' % self.node.uuid,
{}, headers={api_base.Version.string: "1.36"},
expect_errors=True)