diff options
author | Jenkins <jenkins@review.openstack.org> | 2013-10-29 15:03:02 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2013-10-29 15:03:02 +0000 |
commit | 7abefe2aaf922e3aa8683bc7491a1504324c1f90 (patch) | |
tree | a178a816364f77bce3fe4d780765389878c5eb5a /ironic/tests | |
parent | 409b20b4613024a4786953b6940ccfd161f7b016 (diff) | |
parent | fbdf5c301d498edeacf5d02db918d831c1b1917b (diff) | |
download | ironic-7abefe2aaf922e3aa8683bc7491a1504324c1f90.tar.gz |
Merge "Implement /nodes/UUID/vendor_passthru in the API"
Diffstat (limited to 'ironic/tests')
-rw-r--r-- | ironic/tests/api/test_nodes.py | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/ironic/tests/api/test_nodes.py b/ironic/tests/api/test_nodes.py index a0ab6cf83..202ff85d5 100644 --- a/ironic/tests/api/test_nodes.py +++ b/ironic/tests/api/test_nodes.py @@ -320,21 +320,37 @@ class TestPost(base.FunctionalTest): self.assertRaises(webtest.app.AppError, self.post_json, '/nodes', ndict) - def test_vendor_passthru(self): + def test_vendor_passthru_ok(self): ndict = dbutils.get_test_node() self.post_json('/nodes', ndict) uuid = ndict['uuid'] - # TODO(lucasagomes): When vendor_passthru gets implemented - # remove the expect_errors parameter - response = self.post_json('/nodes/%s/vendor_passthru/method' % uuid, - {'foo': 'bar'}, - expect_errors=True) - # TODO(lucasagomes): it's expected to return 202, but because we are - # passing expect_errors=True to the post_json - # function the return code will be 404. So change - # the return code when vendor_passthru gets - # implemented - self.assertEqual(response.status_code, 404) + info = {'foo': 'bar'} + + with mock.patch.object( + rpcapi.ConductorAPI, 'vendor_passthru') as mock_vendor: + mock_vendor.return_value = 'OK' + response = self.post_json('/nodes/%s/vendor_passthru/test' % uuid, + info, expect_errors=False) + mock_vendor.assert_called_once_with(mock.ANY, uuid, 'test', info) + self.assertEqual(response.body, '"OK"') + self.assertEqual(response.status_code, 202) + + def test_vendor_passthru_no_such_method(self): + ndict = dbutils.get_test_node() + self.post_json('/nodes', ndict) + uuid = ndict['uuid'] + info = {'foo': 'bar'} + + with mock.patch.object( + rpcapi.ConductorAPI, 'vendor_passthru') as mock_vendor: + mock_vendor.side_effect = exception.UnsupportedDriverExtension( + {'driver': ndict['driver'], + 'node': uuid, + 'extension': 'test'}) + response = self.post_json('/nodes/%s/vendor_passthru/test' % uuid, + info, expect_errors=True) + mock_vendor.assert_called_once_with(mock.ANY, uuid, 'test', info) + self.assertEqual(response.status_code, 400) def test_vendor_passthru_without_method(self): ndict = dbutils.get_test_node() |