diff --git a/tripleoclient/tests/fakes.py b/tripleoclient/tests/fakes.py index a3dafe621..75ebd70c7 100644 --- a/tripleoclient/tests/fakes.py +++ b/tripleoclient/tests/fakes.py @@ -163,6 +163,7 @@ class FakePlaybookExecution(utils.TestCommand): def setUp(self, ansible_mock=True): super(FakePlaybookExecution, self).setUp() + self.app.options = FakeOptions() self.app.client_manager.auth_ref = mock.Mock(auth_token="TOKEN") self.app.client_manager.baremetal = mock.Mock() compute = self.app.client_manager.compute = mock.Mock() diff --git a/tripleoclient/tests/v1/overcloud_node/test_overcloud_node.py b/tripleoclient/tests/v1/overcloud_node/test_overcloud_node.py index 8bd82e5a1..a5924950d 100644 --- a/tripleoclient/tests/v1/overcloud_node/test_overcloud_node.py +++ b/tripleoclient/tests/v1/overcloud_node/test_overcloud_node.py @@ -19,6 +19,7 @@ import fixtures import json import mock import os +import sys import tempfile from osc_lib import exceptions as oscexc @@ -75,8 +76,6 @@ class TestDeleteNode(fakes.TestDeleteNode): self.addCleanup(wait_stack.stop) self.app.client_manager.compute.servers.get.return_value = None - # TODO(someone): This test does not pass with autospec=True, it should - # probably be fixed so that it can pass with that. @mock.patch('tripleoclient.utils.run_ansible_playbook', autospec=True) def test_node_delete(self, mock_playbook): @@ -247,9 +246,11 @@ class TestDeleteNode(fakes.TestDeleteNode): ) ]) + @mock.patch('tripleoclient.utils.run_ansible_playbook', + autospec=True) @mock.patch('tripleoclient.workflows.baremetal.expand_roles', autospec=True) - def test_nodes_to_delete(self, mock_expand_roles): + def test_nodes_to_delete(self, mock_expand_roles, mock_playbook): bm_yaml = [{ 'name': 'Compute', 'count': 5, @@ -615,7 +616,19 @@ class TestImportNodeMultiArch(fakes.TestOvercloudNode): with mock.patch('tripleoclient.utils.run_ansible_playbook', autospec=True): - self.cmd.take_action(parsed_args) + file_return_nodes = [ + { + 'uuid': 'MOCK_NODE_UUID' + } + ] + mock_open = mock.mock_open(read_data=json.dumps(file_return_nodes)) + # TODO(cloudnull): Remove this when py27 is dropped + if sys.version_info >= (3, 0): + mock_open_path = 'builtins.open' + else: + mock_open_path = 'tripleoclient.v1.overcloud_node.open' + with mock.patch(mock_open_path, mock_open): + self.cmd.take_action(parsed_args) nodes_list = copy.deepcopy(self.nodes_list) if not no_deploy_image: diff --git a/tripleoclient/tests/v1/test_plugin.py b/tripleoclient/tests/v1/test_plugin.py index 3b07bef5f..d266bc6db 100644 --- a/tripleoclient/tests/v1/test_plugin.py +++ b/tripleoclient/tests/v1/test_plugin.py @@ -32,7 +32,6 @@ class FakePluginV1Client(object): class TestPluginV1(base.TestCommand): def setUp(self): super(TestPluginV1, self).setUp() - self.app.client_manager.tripleoclient = FakePluginV1Client( endpoint=fakes.AUTH_URL, token=fakes.AUTH_TOKEN, diff --git a/tripleoclient/tests/v1/tripleo/test_tripleo_deploy.py b/tripleoclient/tests/v1/tripleo/test_tripleo_deploy.py index 1ae39ad02..f4c7cc33b 100644 --- a/tripleoclient/tests/v1/tripleo/test_tripleo_deploy.py +++ b/tripleoclient/tests/v1/tripleo/test_tripleo_deploy.py @@ -64,8 +64,6 @@ class TestDeployUndercloud(TestPluginV1): self.orc.stacks.create = mock.MagicMock( return_value={'stack': {'id': 'foo'}}) - self.ansible_playbook_cmd = "ansible-playbook" - @mock.patch('tripleoclient.v1.tripleo_deploy.Deploy._is_undercloud_deploy') @mock.patch('tripleoclient.utils.check_hostname') def test_run_preflight_checks(self, mock_check_hostname, mock_uc):