Fix usage of mock due for the latest 1.1.0 mock
unit tests jobs have suffered falled from the latest mock 1.1.0. http://lists.openstack.org/pipermail/openstack-dev/2015-July/069156.html This patch set fixes this. Change-Id: Idcc52ec641b02173680dce2246d2cc3810949353 Closes-Bug: #1473381
This commit is contained in:
parent
a18cd6c8d1
commit
436ffd2c6c
|
@ -69,7 +69,7 @@ class TestApi(test_base.BaseTest):
|
||||||
|
|
||||||
@mock.patch.object(introspect, 'introspect', autospec=True)
|
@mock.patch.object(introspect, 'introspect', autospec=True)
|
||||||
def test_intospect_failed(self, introspect_mock):
|
def test_intospect_failed(self, introspect_mock):
|
||||||
introspect_mock.side_effect = utils.Error("boom")
|
introspect_mock.side_effect = iter([utils.Error("boom")])
|
||||||
res = self.app.post('/v1/introspection/%s' % self.uuid)
|
res = self.app.post('/v1/introspection/%s' % self.uuid)
|
||||||
self.assertEqual(400, res.status_code)
|
self.assertEqual(400, res.status_code)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
|
@ -84,7 +84,7 @@ class TestApi(test_base.BaseTest):
|
||||||
def test_introspect_failed_authentication(self, introspect_mock,
|
def test_introspect_failed_authentication(self, introspect_mock,
|
||||||
auth_mock):
|
auth_mock):
|
||||||
CONF.set_override('auth_strategy', 'keystone')
|
CONF.set_override('auth_strategy', 'keystone')
|
||||||
auth_mock.side_effect = utils.Error('Boom', code=403)
|
auth_mock.side_effect = iter([utils.Error('Boom', code=403)])
|
||||||
res = self.app.post('/v1/introspection/%s' % self.uuid,
|
res = self.app.post('/v1/introspection/%s' % self.uuid,
|
||||||
headers={'X-Auth-Token': 'token'})
|
headers={'X-Auth-Token': 'token'})
|
||||||
self.assertEqual(403, res.status_code)
|
self.assertEqual(403, res.status_code)
|
||||||
|
@ -108,7 +108,7 @@ class TestApi(test_base.BaseTest):
|
||||||
|
|
||||||
@mock.patch.object(process, 'process', autospec=True)
|
@mock.patch.object(process, 'process', autospec=True)
|
||||||
def test_continue_failed(self, process_mock):
|
def test_continue_failed(self, process_mock):
|
||||||
process_mock.side_effect = utils.Error("boom")
|
process_mock.side_effect = iter([utils.Error("boom")])
|
||||||
res = self.app.post('/v1/continue', data='"JSON"')
|
res = self.app.post('/v1/continue', data='"JSON"')
|
||||||
self.assertEqual(400, res.status_code)
|
self.assertEqual(400, res.status_code)
|
||||||
process_mock.assert_called_once_with("JSON")
|
process_mock.assert_called_once_with("JSON")
|
||||||
|
|
|
@ -236,7 +236,7 @@ class TestProcess(BaseTest):
|
||||||
|
|
||||||
@prepare_mocks
|
@prepare_mocks
|
||||||
def test_not_found_in_cache(self, cli, pop_mock, process_mock):
|
def test_not_found_in_cache(self, cli, pop_mock, process_mock):
|
||||||
pop_mock.side_effect = utils.Error('not found')
|
pop_mock.side_effect = iter([utils.Error('not found')])
|
||||||
|
|
||||||
self.assertRaisesRegexp(utils.Error,
|
self.assertRaisesRegexp(utils.Error,
|
||||||
'not found',
|
'not found',
|
||||||
|
@ -257,7 +257,7 @@ class TestProcess(BaseTest):
|
||||||
|
|
||||||
@prepare_mocks
|
@prepare_mocks
|
||||||
def test_expected_exception(self, cli, pop_mock, process_mock):
|
def test_expected_exception(self, cli, pop_mock, process_mock):
|
||||||
process_mock.side_effect = utils.Error('boom')
|
process_mock.side_effect = iter([utils.Error('boom')])
|
||||||
|
|
||||||
self.assertRaisesRegexp(utils.Error, 'boom',
|
self.assertRaisesRegexp(utils.Error, 'boom',
|
||||||
process.process, self.data)
|
process.process, self.data)
|
||||||
|
@ -266,7 +266,7 @@ class TestProcess(BaseTest):
|
||||||
|
|
||||||
@prepare_mocks
|
@prepare_mocks
|
||||||
def test_unexpected_exception(self, cli, pop_mock, process_mock):
|
def test_unexpected_exception(self, cli, pop_mock, process_mock):
|
||||||
process_mock.side_effect = RuntimeError('boom')
|
process_mock.side_effect = iter([RuntimeError('boom')])
|
||||||
|
|
||||||
self.assertRaisesRegexp(utils.Error, 'Unexpected exception',
|
self.assertRaisesRegexp(utils.Error, 'Unexpected exception',
|
||||||
process.process, self.data)
|
process.process, self.data)
|
||||||
|
@ -292,7 +292,7 @@ class TestProcess(BaseTest):
|
||||||
def test_hook_unexpected_exceptions_no_node(self, cli, pop_mock,
|
def test_hook_unexpected_exceptions_no_node(self, cli, pop_mock,
|
||||||
process_mock):
|
process_mock):
|
||||||
# Check that error from hooks is raised, not "not found"
|
# Check that error from hooks is raised, not "not found"
|
||||||
pop_mock.side_effect = utils.Error('not found')
|
pop_mock.side_effect = iter([utils.Error('not found')])
|
||||||
for ext in plugins_base.processing_hooks_manager():
|
for ext in plugins_base.processing_hooks_manager():
|
||||||
patcher = mock.patch.object(ext.obj, 'before_processing',
|
patcher = mock.patch.object(ext.obj, 'before_processing',
|
||||||
side_effect=RuntimeError('boom'))
|
side_effect=RuntimeError('boom'))
|
||||||
|
@ -307,7 +307,7 @@ class TestProcess(BaseTest):
|
||||||
@prepare_mocks
|
@prepare_mocks
|
||||||
def test_error_if_node_not_found_hook(self, cli, pop_mock, process_mock):
|
def test_error_if_node_not_found_hook(self, cli, pop_mock, process_mock):
|
||||||
plugins_base._NOT_FOUND_HOOK_MGR = None
|
plugins_base._NOT_FOUND_HOOK_MGR = None
|
||||||
pop_mock.side_effect = utils.NotFoundInCacheError('BOOM')
|
pop_mock.side_effect = iter([utils.NotFoundInCacheError('BOOM')])
|
||||||
self.assertRaisesRegexp(utils.Error,
|
self.assertRaisesRegexp(utils.Error,
|
||||||
'Look up error: BOOM',
|
'Look up error: BOOM',
|
||||||
process.process, self.data)
|
process.process, self.data)
|
||||||
|
@ -316,7 +316,7 @@ class TestProcess(BaseTest):
|
||||||
def test_node_not_found_hook_run_ok(self, cli, pop_mock, process_mock):
|
def test_node_not_found_hook_run_ok(self, cli, pop_mock, process_mock):
|
||||||
CONF.set_override('node_not_found_hook', 'example', 'processing')
|
CONF.set_override('node_not_found_hook', 'example', 'processing')
|
||||||
plugins_base._NOT_FOUND_HOOK_MGR = None
|
plugins_base._NOT_FOUND_HOOK_MGR = None
|
||||||
pop_mock.side_effect = utils.NotFoundInCacheError('BOOM')
|
pop_mock.side_effect = iter([utils.NotFoundInCacheError('BOOM')])
|
||||||
with mock.patch.object(example_plugin,
|
with mock.patch.object(example_plugin,
|
||||||
'example_not_found_hook') as hook_mock:
|
'example_not_found_hook') as hook_mock:
|
||||||
hook_mock.return_value = node_cache.NodeInfo(
|
hook_mock.return_value = node_cache.NodeInfo(
|
||||||
|
@ -330,7 +330,7 @@ class TestProcess(BaseTest):
|
||||||
def test_node_not_found_hook_run_none(self, cli, pop_mock, process_mock):
|
def test_node_not_found_hook_run_none(self, cli, pop_mock, process_mock):
|
||||||
CONF.set_override('node_not_found_hook', 'example', 'processing')
|
CONF.set_override('node_not_found_hook', 'example', 'processing')
|
||||||
plugins_base._NOT_FOUND_HOOK_MGR = None
|
plugins_base._NOT_FOUND_HOOK_MGR = None
|
||||||
pop_mock.side_effect = utils.NotFoundInCacheError('BOOM')
|
pop_mock.side_effect = iter([utils.NotFoundInCacheError('BOOM')])
|
||||||
with mock.patch.object(example_plugin,
|
with mock.patch.object(example_plugin,
|
||||||
'example_not_found_hook') as hook_mock:
|
'example_not_found_hook') as hook_mock:
|
||||||
hook_mock.return_value = None
|
hook_mock.return_value = None
|
||||||
|
@ -343,7 +343,7 @@ class TestProcess(BaseTest):
|
||||||
def test_node_not_found_hook_exception(self, cli, pop_mock, process_mock):
|
def test_node_not_found_hook_exception(self, cli, pop_mock, process_mock):
|
||||||
CONF.set_override('node_not_found_hook', 'example', 'processing')
|
CONF.set_override('node_not_found_hook', 'example', 'processing')
|
||||||
plugins_base._NOT_FOUND_HOOK_MGR = None
|
plugins_base._NOT_FOUND_HOOK_MGR = None
|
||||||
pop_mock.side_effect = utils.NotFoundInCacheError('BOOM')
|
pop_mock.side_effect = iter([utils.NotFoundInCacheError('BOOM')])
|
||||||
with mock.patch.object(example_plugin,
|
with mock.patch.object(example_plugin,
|
||||||
'example_not_found_hook') as hook_mock:
|
'example_not_found_hook') as hook_mock:
|
||||||
hook_mock.side_effect = Exception('Hook Error')
|
hook_mock.side_effect = Exception('Hook Error')
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[metadata]
|
[metadata]
|
||||||
name = ironic-inspector
|
name = ironic-inspector
|
||||||
summary = Hardware introspection for Ironic
|
summary = Hardware introspection for Ironic
|
||||||
version = 2.1.0
|
version = 2.0.1
|
||||||
description-file = README.rst
|
description-file = README.rst
|
||||||
home-page = https://launchpad.net/ironic-inspector
|
home-page = https://launchpad.net/ironic-inspector
|
||||||
license = Apache-2
|
license = Apache-2
|
||||||
|
|
Loading…
Reference in New Issue