Use unittest.mock instead of third party mock

Now that we no longer support py27, we can use the standard library
unittest.mock module instead of the third party mock lib.

Co-Authored-By: Alex Schultz <aschultz@redhat.com>
Change-Id: I642a46b31586f2791c510645f475effd52ce304e
changes/92/785892/7
Sandeep Yadav 2 years ago committed by Alex Schultz
parent afbd091df9
commit 5084da8196

@ -4,7 +4,6 @@
coverage!=4.4,>=4.0 # Apache-2.0
docutils>=0.11 # OSI-Approved Open Source, Public Domain
fixtures>=3.0.0 # Apache-2.0/BSD
mock>=3.0.0 # BSD
stestr>=2.0.0 # Apache-2.0
testtools>=2.2.0 # MIT
requests-mock>=1.2.0 # Apache-2.0

@ -14,8 +14,8 @@
#
import logging
import mock
import sys
from unittest import mock
from osc_lib.tests import utils

@ -15,7 +15,7 @@
from json.decoder import JSONDecodeError
import os
import mock
from unittest import mock
from unittest import TestCase
from tripleoclient import export

@ -13,12 +13,12 @@
# under the License.
import fixtures
import mock
import os
from pathlib import Path
import shutil
import subprocess
import time
from unittest import mock
from tripleoclient import heat_launcher
from tripleoclient.exceptions import HeatPodMessageQueueException
@ -47,13 +47,6 @@ class TestHeatPodLauncher(base.TestCase):
use_tmp_dir=False,
**kwargs)
def check_calls(self, check_call, mock_obj):
for call in mock_obj.call_args_list:
call_str = ' '.join(call.args[0])
if check_call in call_str:
return True
return False
def test_rm_heat_launcher(self):
self.assertIsInstance(self.get_launcher(rm_heat=True),
heat_launcher.HeatPodLauncher)
@ -61,49 +54,58 @@ class TestHeatPodLauncher(base.TestCase):
def test_chcon(self):
launcher = self.get_launcher()
launcher._chcon()
self.check_calls('chcon', self.check_call)
self.check_calls(launcher.heat_dir, self.check_call)
calls = [
mock.call(['chcon', '-R', '-t', 'container_file_t', '-l', 's0',
launcher.heat_dir]),
mock.call(['chcon', '-R', '-t', 'container_file_t', '-l', 's0',
launcher.heat_dir])
]
self.assertEqual(self.check_call.mock_calls, calls)
def test_fetch_container_image(self):
launcher = self.get_launcher(skip_heat_pull=True)
self.check_output.reset_mock()
launcher._fetch_container_image()
self.assertFalse(self.check_calls('podman pull', self.check_output))
self.check_output.assert_not_called()
launcher = self.get_launcher(skip_heat_pull=False)
launcher._fetch_container_image()
self.assertTrue(self.check_calls('podman pull', self.check_output))
self.check_output.assert_called_with(['sudo', 'podman', 'pull',
mock.ANY])
@mock.patch('tripleoclient.heat_launcher.HeatPodLauncher._decode')
def test_get_pod_state(self, mock_decode):
launcher = self.get_launcher()
launcher.get_pod_state()
self.check_calls('podman pod inspect', self.run)
self.assertTrue(mock_decode.called)
self.run.assert_called_once_with(
['sudo', 'podman', 'pod', 'inspect', '--format', '"{{.State}}"',
'ephemeral-heat'], check=False, stderr=-2, stdout=-1)
@mock.patch(
'tripleoclient.heat_launcher.HeatPodLauncher._write_heat_config')
@mock.patch('tripleoclient.heat_launcher.HeatPodLauncher._write_heat_pod')
@mock.patch('tripleoclient.heat_launcher.HeatPodLauncher.get_pod_state')
def test_lauch_heat(
def test_launch_heat(
self, mock_get_pod_state, mock_write_heat_pod,
mock_write_heat_config):
launcher = self.get_launcher()
self.check_call.reset_mock()
mock_get_pod_state.return_value = 'Running'
launcher.launch_heat()
self.assertFalse(mock_write_heat_pod.called)
self.assertFalse(self.check_calls('podman play kube', self.check_call))
self.check_call.assert_not_called()
mock_get_pod_state.return_value = 'Exited'
launcher.launch_heat()
self.assertTrue(mock_write_heat_pod.called)
self.assertTrue(self.check_calls('podman play kube', self.check_call))
self.check_call.assert_called_once_with(['sudo', 'podman', 'play',
'kube', mock.ANY])
self.check_call.reset_mock()
mock_get_pod_state.return_value = ''
launcher.launch_heat()
self.assertTrue(mock_write_heat_pod.called)
self.assertTrue(self.check_calls('podman play kube', self.check_call))
self.check_call.assert_called_once_with(['sudo', 'podman', 'play',
'kube', mock.ANY])
@mock.patch('tripleoclient.heat_launcher.HeatPodLauncher.do_restore_db')
@mock.patch('tripleoclient.heat_launcher.HeatPodLauncher.database_exists')
@ -113,43 +115,72 @@ class TestHeatPodLauncher(base.TestCase):
launcher = self.get_launcher()
mock_db_exists.return_value = True
launcher.heat_db_sync(restore_db=False)
self.assertFalse(self.check_calls('create database', self.check_call))
self.assertFalse(self.check_calls('create user', self.check_call))
self.assertFalse(self.check_calls('grant all', self.check_call))
self.assertFalse(self.check_calls('flush priv', self.check_call))
self.assertTrue(self.check_calls('heat-manage', self.check_call))
calls = [
mock.call(['chcon', '-R', '-t', 'container_file_t', '-l', 's0',
mock.ANY]),
mock.call(['sudo', 'podman', 'run', '--rm', '--user', 'heat',
'--volume', mock.ANY, '--volume', mock.ANY,
'quay.io/tripleomaster/openstack-heat-api:current-'
'tripleo',
'heat-manage', 'db_sync'])
]
self.assertEqual(self.check_call.mock_calls, calls)
self.assertFalse(mock_do_restore_db.called)
self.check_call.reset_mock()
mock_db_exists.return_value = True
launcher.heat_db_sync(restore_db=True)
self.assertFalse(self.check_calls('create database', self.check_call))
self.assertFalse(self.check_calls('create user', self.check_call))
self.assertFalse(self.check_calls('grant all', self.check_call))
self.assertFalse(self.check_calls('flush priv', self.check_call))
self.assertTrue(self.check_calls('heat-manage', self.check_call))
self.check_call.assert_called_once_with([
'sudo', 'podman', 'run', '--rm', '--user', 'heat', '--volume',
mock.ANY, '--volume', mock.ANY,
'quay.io/tripleomaster/openstack-heat-api:current-tripleo',
'heat-manage', 'db_sync'])
self.assertTrue(mock_do_restore_db.called)
self.check_call.reset_mock()
mock_db_exists.return_value = False
launcher.heat_db_sync(restore_db=True)
self.assertTrue(self.check_calls('create database', self.check_call))
self.assertTrue(self.check_calls('create user', self.check_call))
self.assertTrue(self.check_calls('grant all', self.check_call))
self.assertTrue(self.check_calls('flush priv', self.check_call))
self.assertTrue(self.check_calls('heat-manage', self.check_call))
calls = [
mock.call(['sudo', 'podman', 'exec', '-u', 'root', 'mysql',
'mysql', '-e', 'create database heat']),
mock.call(['sudo', 'podman', 'exec', '-u', 'root', 'mysql',
'mysql', '-e', "create user if not exists 'heat'@'%' "
"identified by 'heat'"]),
mock.call(['sudo', 'podman', 'exec', '-u', 'root', 'mysql',
'mysql', 'heat', '-e', "grant all privileges on heat.* "
"to 'heat'@'%'"]),
mock.call(['sudo', 'podman', 'exec', '-u', 'root', 'mysql',
'mysql', '-e', 'flush privileges;']),
mock.call(['sudo', 'podman', 'run', '--rm', '--user', 'heat',
'--volume', mock.ANY, '--volume', mock.ANY,
'quay.io/tripleomaster/openstack-heat-api:current-'
'tripleo', 'heat-manage', 'db_sync'])
]
self.assertEqual(self.check_call.mock_calls, calls)
self.assertTrue(mock_do_restore_db.called)
self.check_call.reset_mock()
mock_do_restore_db.reset_mock()
mock_db_exists.return_value = False
launcher.heat_db_sync(restore_db=False)
self.assertTrue(self.check_calls('create database', self.check_call))
self.assertTrue(self.check_calls('create user', self.check_call))
self.assertTrue(self.check_calls('grant all', self.check_call))
self.assertTrue(self.check_calls('flush priv', self.check_call))
self.assertTrue(self.check_calls('heat-manage', self.check_call))
calls = [
mock.call(['sudo', 'podman', 'exec', '-u', 'root', 'mysql',
'mysql', '-e', 'create database heat']),
mock.call(['sudo', 'podman', 'exec', '-u', 'root', 'mysql',
'mysql', '-e', "create user if not exists 'heat'@'%' "
"identified by 'heat'"]),
mock.call(['sudo', 'podman', 'exec', '-u', 'root', 'mysql',
'mysql', 'heat', '-e', "grant all privileges on heat.* "
"to 'heat'@'%'"]),
mock.call(['sudo', 'podman', 'exec', '-u', 'root', 'mysql',
'mysql', '-e', 'flush privileges;']),
mock.call(['sudo', 'podman', 'run', '--rm', '--user', 'heat',
'--volume', mock.ANY, '--volume', mock.ANY,
'quay.io/tripleomaster/openstack-heat-api:current-'
'tripleo', 'heat-manage', 'db_sync'])
]
self.assertEqual(self.check_call.mock_calls, calls)
self.assertFalse(mock_do_restore_db.called)
@mock.patch('os.unlink')
@ -217,17 +248,27 @@ class TestHeatPodLauncher(base.TestCase):
p.unlink()
launcher.do_backup_db()
mock_tar.assert_called_with(str(p))
self.assertTrue(self.check_calls('mysqldump heat', self.run))
self.run.assert_called_once_with(['sudo', 'podman', 'exec', '-u',
'root', 'mysql', 'mysqldump',
'heat'],
check=True, stdout=mock.ANY)
def test_pod_exists(self):
launcher = self.get_launcher()
self.check_call.reset_mock()
self.assertTrue(launcher.pod_exists())
self.check_calls('pod inspect', self.check_call)
self.check_call.assert_called_once_with(['sudo', 'podman', 'pod',
'inspect', 'ephemeral-heat'],
stderr=subprocess.DEVNULL,
stdout=subprocess.DEVNULL)
self.check_call.reset_mock()
self.check_call.side_effect = subprocess.CalledProcessError(1, 'test')
self.assertFalse(launcher.pod_exists())
self.check_calls('pod inspect', self.check_call)
self.check_call.assert_called_once_with(['sudo', 'podman', 'pod',
'inspect', 'ephemeral-heat'],
stderr=subprocess.DEVNULL,
stdout=subprocess.DEVNULL)
@mock.patch('os.path.exists')
@mock.patch('tripleoclient.heat_launcher.HeatPodLauncher.tar_file')
@ -241,6 +282,7 @@ class TestHeatPodLauncher(base.TestCase):
launcher = self.get_launcher()
launcher.log_dir = '/log'
self.check_call.reset_mock()
mock_db_exists.return_value = True
mock_pod_exists.return_value = True
@ -250,10 +292,16 @@ class TestHeatPodLauncher(base.TestCase):
'log_file': 'heat-log'}}
launcher.rm_heat()
mock_backup_db.assert_called()
self.check_calls('drop database heat', self.check_call)
self.check_calls('drop user', self.check_call)
calls = [
mock.call(['sudo', 'podman', 'exec', '-u', 'root', 'mysql',
'mysql', 'heat', '-e', 'drop database heat']),
mock.call(['sudo', 'podman', 'exec', '-u', 'root', 'mysql',
'mysql', '-e', "drop user 'heat'@'%'"])
]
self.assertEqual(self.check_call.mock_calls, calls)
mock_pod_exists.assert_called()
self.check_calls('podman pod rm -f', self.call)
self.call.assert_called_once_with(['sudo', 'podman', 'pod', 'rm', '-f',
'ephemeral-heat'])
mock_read_heat_config.assert_called()
mock_tar.assert_called_with('/log/heat-log')
@ -277,18 +325,21 @@ class TestHeatPodLauncher(base.TestCase):
mock_exists.return_value = True
launcher.rm_heat(backup_db=False)
mock_backup_db.assert_not_called()
self.check_calls('podman pod rm -f', self.call)
self.call.assert_called_once_with(['sudo', 'podman', 'pod', 'rm', '-f',
'ephemeral-heat'])
@mock.patch('tripleoclient.heat_launcher.HeatPodLauncher.get_pod_state')
@mock.patch('tripleoclient.heat_launcher.HeatPodLauncher.pod_exists')
def test_stop_heat(self, mock_pod_exists, mock_pod_state):
launcher = self.get_launcher()
self.check_call.reset_mock()
mock_pod_exists.return_value = True
mock_pod_state.return_value = 'Running'
launcher.stop_heat()
mock_pod_exists.assert_called()
mock_pod_state.assert_called()
self.check_calls('podman pod stop', self.check_call)
self.check_call.asert_called_once_with(['sudo', 'podman', 'pod',
'stop', 'ephemeral-heat'])
self.check_call.reset_mock()
mock_pod_exists.reset_mock()
@ -312,8 +363,13 @@ class TestHeatPodLauncher(base.TestCase):
def test_check_message_bus(self):
launcher = self.get_launcher()
self.check_call.reset_mock()
launcher.check_message_bus()
self.check_calls('rabbitmqctl list_queues', self.check_call)
self.check_call.assert_called_once_with(['sudo', 'podman', 'exec',
'-u', 'root', 'rabbitmq',
'rabbitmqctl', 'list_queues'],
stderr=subprocess.DEVNULL,
stdout=subprocess.DEVNULL)
self.check_call.reset_mock()
self.check_call.side_effect = subprocess.CalledProcessError(1, 'test')
@ -324,11 +380,17 @@ class TestHeatPodLauncher(base.TestCase):
'tripleoclient.heat_launcher.HeatPodLauncher._get_ctlplane_ip')
def test_check_database(self, mock_ctlplane_ip):
launcher = self.get_launcher()
self.check_call.reset_mock()
mock_ctlplane_ip.return_value = '1.1.1.1'
self.assertTrue(launcher.check_database())
mock_ctlplane_ip.assert_called()
self.check_calls('show databases', self.check_call)
self.check_call.assert_called_once_with(['sudo', 'podman', 'exec',
'-u', 'root', 'mysql',
'mysql', '-h', '1.1.1.1',
'-e', 'show databases;'],
stderr=subprocess.DEVNULL,
stdout=subprocess.DEVNULL)
self.check_call.reset_mock()
mock_ctlplane_ip.reset_mock()
@ -338,21 +400,28 @@ class TestHeatPodLauncher(base.TestCase):
def test_database_exists(self):
launcher = self.get_launcher()
self.check_output.reset_mock()
self.check_output.return_value = 'heat'
self.assertTrue(launcher.database_exists())
self.check_calls('show databases like "heat"', self.check_output)
self.check_output.assert_called_once_with([
'sudo', 'podman', 'exec', '-u', 'root', 'mysql', 'mysql', '-e',
'show databases like "heat"'])
self.check_output.reset_mock()
self.check_output.return_value = 'nova'
self.assertFalse(launcher.database_exists())
self.check_calls('show databases like "heat"', self.check_output)
self.check_output.assert_called_once_with([
'sudo', 'podman', 'exec', '-u', 'root', 'mysql', 'mysql', '-e',
'show databases like "heat"'])
@mock.patch('tripleoclient.heat_launcher.HeatPodLauncher.pod_exists')
def test_kill_heat(self, mock_pod_exists):
launcher = self.get_launcher()
self.check_output.reset_mock()
mock_pod_exists.return_value = True
launcher.kill_heat(0)
self.check_calls('podman pod kill', self.call)
self.call.assert_called_once_with(['sudo', 'podman', 'pod', 'kill',
'ephemeral-heat'])
mock_pod_exists.assert_called()
mock_pod_exists.reset_mock()
@ -394,17 +463,21 @@ class TestHeatPodLauncher(base.TestCase):
@mock.patch('tripleoclient.heat_launcher.HeatPodLauncher._decode')
def test_get_ctlplane_vip(self, mock_decode):
launcher = self.get_launcher()
self.check_output.reset_mock()
self.check_output.return_value = '1.1.1.1'
launcher._get_ctlplane_vip()
self.check_calls('sudo hiera controller_virtual_ip', self.check_output)
self.check_output.assert_called_once_with(['sudo', 'hiera',
'controller_virtual_ip'])
mock_decode.assert_called_with('1.1.1.1')
@mock.patch('tripleoclient.heat_launcher.HeatPodLauncher._decode')
def test_get_ctlplane_ip(self, mock_decode):
launcher = self.get_launcher()
self.check_output.reset_mock()
self.check_output.return_value = '1.1.1.1'
launcher._get_ctlplane_ip()
self.check_calls('sudo hiera ctlplane', self.check_output)
self.check_output.assert_called_once_with(['sudo', 'hiera',
'ctlplane'])
mock_decode.assert_called_with('1.1.1.1')
@mock.patch('multiprocessing.cpu_count')

@ -11,9 +11,9 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import mock
import shutil
import tempfile
from unittest import mock
from tripleoclient.tests.v1 import test_plugin
from tripleoclient.v1 import overcloud_credentials

@ -12,7 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from tripleoclient import plugin
from tripleoclient.tests import base

@ -19,7 +19,6 @@ import argparse
import datetime
import fixtures
import logging
import mock
import openstack
import os
import os.path
@ -27,6 +26,7 @@ import shutil
import socket
import subprocess
import tempfile
from unittest import mock
import sys

@ -13,7 +13,7 @@
# under the License.
#
import mock
from unittest import mock
import ironic_inspector_client
from osc_lib.tests import utils

@ -13,7 +13,7 @@
# under the License.
#
import mock
from unittest import mock
from osc_lib.tests import utils

@ -10,7 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from osc_lib.tests import utils

@ -13,7 +13,7 @@
# under the License.
#
import mock
from unittest import mock
from tripleoclient.tests import fakes

@ -19,8 +19,8 @@ import os
import shutil
import tempfile
import yaml
from unittest import mock
import mock
from osc_lib import exceptions as oscexc
from osc_lib.tests import utils
@ -306,6 +306,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
mock_rc_params, mock_default_image_params,
mock_stack_data, mock_provision_networks,
mock_provision_virtual_ips):
mock_tmpdir.return_value = self.tmp_dir.path
fixture = deployment.DeploymentWorkflowFixture()
self.useFixture(fixture)
utils_fixture = deployment.UtilsFixture()
@ -415,6 +416,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
mock_image_prepare, mock_generate_password,
mock_rc_params, mock_stack_data,
mock_provision_networks, mock_provision_virtual_ips):
mock_tmpdir.return_value = self.tmp_dir.path
fixture = deployment.DeploymentWorkflowFixture()
self.useFixture(fixture)
utils_fixture = deployment.UtilsFixture()
@ -833,6 +835,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
mock_generate_password, mock_rc_params,
mock_check_service_vip_migr,
mock_provision_networks, mock_provision_virtual_ips):
mock_tmpdir.return_value = self.tmp_dir.path
fixture = deployment.DeploymentWorkflowFixture()
self.useFixture(fixture)
clients = self.app.client_manager

@ -14,8 +14,8 @@
#
import fixtures
import mock
import os
from unittest import mock
from tripleoclient.tests import fakes as ooofakes
from tripleoclient.tests.v1.overcloud_external_update import fakes

@ -13,7 +13,7 @@
# under the License.
#
import mock
from unittest import mock
from tripleoclient.tests import fakes as ooofakes
from tripleoclient.tests.v1.overcloud_external_upgrade import fakes

@ -14,8 +14,8 @@
#
from datetime import datetime
import mock
import os
from unittest import mock
from osc_lib import exceptions
import tripleo_common.arch

@ -13,9 +13,9 @@
# under the License.
#
import mock
import os
import tempfile
from unittest import mock
import yaml

@ -13,7 +13,7 @@
# under the License.
#
import mock
from unittest import mock
from tripleoclient.tests import fakes

@ -17,9 +17,9 @@ import collections
import copy
import fixtures
import json
import mock
import os
import tempfile
from unittest import mock
from osc_lib import exceptions as oscexc
from osc_lib.tests import utils as test_utils

@ -13,7 +13,7 @@
# under the License.
#
import mock
from unittest import mock
from tripleo_common.exception import NotFound
from tripleoclient.tests.v1.overcloud_deploy import fakes

@ -13,7 +13,7 @@
# under the License.
#
import mock
from unittest import mock
from osc_lib.tests.utils import ParserException
from tripleoclient import constants

@ -13,7 +13,7 @@
# under the License.
#
import mock
from unittest import mock
from osc_lib import exceptions as oscexc
from osc_lib.tests.utils import ParserException

@ -15,7 +15,6 @@
import fixtures
from io import StringIO
import mock
import os
import requests
import shutil
@ -24,6 +23,7 @@ import tempfile
from urllib import parse
import uuid
import yaml
from unittest import mock
from osc_lib import exceptions as oscexc
from tripleo_common.image import kolla_builder

@ -10,7 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from tripleoclient.tests.v1 import test_plugin
from tripleoclient import utils

@ -11,8 +11,8 @@
# under the License.
import json
import mock
import tempfile
from unittest import mock
from osc_lib.tests import utils as test_utils
@ -51,7 +51,6 @@ class TestConfigureBIOS(Base):
autospec=True
)
playbook_runner.start()
self.addCleanup(playbook_runner.stop)
def test_configure_specified_nodes_ok(self):
conf = json.dumps(self.conf)
@ -150,7 +149,6 @@ class TestResetBIOS(Base):
autospec=True
)
playbook_runner.start()
self.addCleanup(playbook_runner.stop)
def test_reset_specified_nodes_ok(self):
arglist = ['node_uuid1', 'node_uuid2']

@ -13,7 +13,7 @@
# under the License.
import os
import mock
from unittest import mock
from osc_lib.tests import utils

@ -13,7 +13,7 @@
# under the License.
import os
import mock
from unittest import mock
from osc_lib.tests import utils

@ -10,7 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from osc_lib.tests import utils

@ -12,7 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from tripleoclient import exceptions
from tripleoclient.tests import fakes

@ -11,8 +11,8 @@
# under the License.
import json
import mock
import tempfile
from unittest import mock
from osc_lib.tests import utils as test_utils
@ -49,7 +49,6 @@ class TestCreateRAID(fakes.TestBaremetal):
autospec=True
)
playbook_runner.start()
self.addCleanup(playbook_runner.stop)
def test_ok(self):
conf = json.dumps(self.conf)

@ -13,7 +13,7 @@
# under the License.
#
import mock
from unittest import mock
from tripleoclient.tests import base
from tripleoclient.tests import fakes

@ -18,10 +18,7 @@ Tests basic parser behavior, with both default and user supplied
values of arguments.
Further assertions are placed on results of the parser.
"""
try:
from unittest import mock
except ImportError:
import mock
from unittest import mock
from tripleoclient.tests import base

@ -13,10 +13,7 @@
# under the License.
#
try:
from unittest import mock
except ImportError:
import mock
from unittest import mock
from tripleoclient.tests import base

@ -13,11 +13,11 @@
# under the License.
#
import mock
import os
import sys
import tempfile
import yaml
from unittest import mock
from heatclient import exc as hc_exc
@ -553,7 +553,7 @@ class TestDeployUndercloud(TestPluginV1):
for call in mock_yaml_dump.call_args_list:
args, kwargs = call
for a in args:
if isinstance(a, mock.mock.MagicMock):
if isinstance(a, mock.MagicMock):
continue
if a.get('parameter_defaults', {}).get('StackAction', None):
self.assertTrue(
@ -1157,9 +1157,9 @@ class TestDeployUndercloud(TestPluginV1):
'--output-only'], [])
self.cmd.take_action(parsed_args)
self.assertEqual(1, mock_ac.call_count)
self.assertEqual(
"local", mock_ac.call_args_list[0].kwargs["transport"])
call = mock.call('/foo', mock.ANY, ssh_private_key=None,
transport='local')
self.assertEqual(mock_ac.mock_calls, [call])
# Test transport "ssh"
mock_ac.reset_mock()
@ -1172,5 +1172,6 @@ class TestDeployUndercloud(TestPluginV1):
'--transport', 'ssh'], [])
self.cmd.take_action(parsed_args)
self.assertEqual(1, mock_ac.call_count)
self.assertEqual("ssh", mock_ac.call_args_list[0].kwargs["transport"])
call = mock.call('/foo', mock.ANY, ssh_private_key=None,
transport='ssh')
self.assertEqual(mock_ac.mock_calls, [call])

@ -13,7 +13,7 @@
# under the License.
#
import mock
from unittest import mock
from osc_lib.tests import utils

@ -13,7 +13,7 @@
# under the License.
#
import mock
from unittest import mock
from osc_lib.tests import utils

@ -20,8 +20,8 @@ from cryptography import x509
from cryptography.x509.oid import NameOID
from datetime import datetime
from datetime import timedelta
from unittest import mock
import fixtures
import mock
import os
import tempfile
import yaml

@ -15,8 +15,8 @@
import fixtures
import json
import mock
import os
from unittest import mock
from jinja2 import Template

@ -13,7 +13,7 @@
# under the License.
#
import mock
from unittest import mock
from tripleoclient.tests import fakes
from tripleoclient.tests.v1.overcloud_deploy import fakes as deploy_fakes

@ -13,7 +13,7 @@
# under the License.
#
import mock
from unittest import mock
from osc_lib import exceptions as osc_lib_exc

@ -14,7 +14,8 @@
#
import tempfile
import mock
from unittest import mock
from osc_lib import exceptions
from tripleoclient import constants

@ -13,7 +13,7 @@
# under the License.
#
import mock
from unittest import mock
from osc_lib import exceptions as osc_lib_exc

@ -16,9 +16,9 @@
import collections
import fixtures
import json
import mock
import os
import tempfile
from unittest import mock
from osc_lib.tests import utils as test_utils

@ -13,8 +13,8 @@
# under the License.
#
import mock
import os
from unittest import mock
from osc_lib.tests import utils

@ -12,8 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
import netaddr
from unittest import mock
import ironic_inspector_client
from oslo_concurrency import processutils

@ -12,10 +12,11 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
import os
import shutil
import tempfile
from unittest import mock
from osc_lib.tests import utils

@ -12,7 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from unittest import mock
from osc_lib.tests import utils

Loading…
Cancel
Save