Support mock==1.8.0 in unit tests
Use assert_called_once_with instead of assert_called_once that was introduced in 2.0.0. Change-Id: Ifb7699d4b552d148984961727355f0e23b487c7c
This commit is contained in:
parent
0a480b96cc
commit
b34d749f1c
|
@ -164,7 +164,7 @@ def test_path_restore(mocker, cls, path, members):
|
||||||
subprocess_mock.assert_called_once_with(
|
subprocess_mock.assert_called_once_with(
|
||||||
["fuel-bootstrap", "build", "--activate"],
|
["fuel-bootstrap", "build", "--activate"],
|
||||||
env={'OS_PASSWORD': 'password', 'OS_USERNAME': 'user'})
|
env={'OS_PASSWORD': 'password', 'OS_USERNAME': 'user'})
|
||||||
get_images.assert_called_once()
|
get_images.assert_called_once_with()
|
||||||
delete_image.assert_called_once_with(fake_uuids[0])
|
delete_image.assert_called_once_with(fake_uuids[0])
|
||||||
else:
|
else:
|
||||||
assert not subprocess_mock.called
|
assert not subprocess_mock.called
|
||||||
|
|
|
@ -54,10 +54,13 @@ def test_upgrade_node(mocker, node_ids, isolated, network_template,
|
||||||
node.data['id'] = node_id
|
node.data['id'] = node_id
|
||||||
node.data['cluster'] = None
|
node.data['cluster'] = None
|
||||||
node.data['roles'] = 'controller'
|
node.data['roles'] = 'controller'
|
||||||
|
mock_nodes_list.append(node)
|
||||||
return node
|
return node
|
||||||
|
|
||||||
|
mock_nodes_list = []
|
||||||
test_env_id = 'test-env'
|
test_env_id = 'test-env'
|
||||||
mock_env = mocker.patch("fuelclient.objects.environment.Environment")
|
mock_env_class = mocker.patch("fuelclient.objects.environment.Environment")
|
||||||
|
mock_env = mock_env_class.return_value
|
||||||
mock_env.id = test_env_id
|
mock_env.id = test_env_id
|
||||||
mock_env.data = {}
|
mock_env.data = {}
|
||||||
mock_env.data['id'] = mock_env.id
|
mock_env.data['id'] = mock_env.id
|
||||||
|
@ -77,18 +80,19 @@ def test_upgrade_node(mocker, node_ids, isolated, network_template,
|
||||||
mock_deploy_changes = mocker.patch("octane.util.env.deploy_changes")
|
mock_deploy_changes = mocker.patch("octane.util.env.deploy_changes")
|
||||||
upgrade_node.upgrade_node(test_env_id, node_ids)
|
upgrade_node.upgrade_node(test_env_id, node_ids)
|
||||||
|
|
||||||
mock_copy_patches.assert_called_once()
|
mock_copy_patches.assert_called_once_with()
|
||||||
mock_copy_vips.assert_called_once_with(mock_env.return_value)
|
mock_copy_vips.assert_called_once_with(mock_env)
|
||||||
mock_move_nodes.assert_called_once()
|
mock_move_nodes.assert_called_once_with(mock_env, mock_nodes_list,
|
||||||
|
True, None)
|
||||||
assert mock_handlers.call_args_list == [
|
assert mock_handlers.call_args_list == [
|
||||||
mock.call('preupgrade'), mock.call('prepare'),
|
mock.call('preupgrade'), mock.call('prepare'),
|
||||||
mock.call('predeploy'), mock.call('postdeploy')]
|
mock.call('predeploy'), mock.call('postdeploy')]
|
||||||
if network_template:
|
if network_template:
|
||||||
mock_load_network_template.assert_called_once_with(network_template)
|
mock_load_network_template.assert_called_once_with(network_template)
|
||||||
if isolated:
|
if isolated:
|
||||||
mock_deploy_nodes.assert_called_once()
|
mock_deploy_nodes.assert_called_once_with(mock_env, mock_nodes_list)
|
||||||
else:
|
else:
|
||||||
mock_deploy_changes.assert_called_once()
|
mock_deploy_changes.assert_called_once_with(mock_env, mock_nodes_list)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('node_data,expected_error', [
|
@pytest.mark.parametrize('node_data,expected_error', [
|
||||||
|
|
Loading…
Reference in New Issue