Fix all py27 tests

This change fixes our py27 tests. The issue was a cascading failure caused
by a bad mock for sys.stdout.flush which results in general failure when
calling system and other builtin functions.

Change-Id: Ia1a108e77dd50404b78d952c9c9a9c0d534a5d28
Signed-off-by: Kevin Carter <kecarter@redhat.com>
(cherry picked from commit 6aa5cdd3b0)
This commit is contained in:
Kevin Carter 2020-01-29 11:59:38 -06:00 committed by Kevin Carter (cloudnull)
parent d09212f5ed
commit fe961790f3
1 changed files with 9 additions and 9 deletions

View File

@ -815,11 +815,10 @@ class TestDeployUndercloud(TestPluginV1):
'_launch_heat', autospec=True) '_launch_heat', autospec=True)
@mock.patch('tripleo_common.utils.config.Config', @mock.patch('tripleo_common.utils.config.Config',
autospec=True) autospec=True)
@mock.patch('tripleoclient.v1.tripleo_deploy.sys.stdout.flush')
@mock.patch('os.path.join', return_value='/twd/inventory.yaml') @mock.patch('os.path.join', return_value='/twd/inventory.yaml')
def test_download_ansible_playbooks(self, mock_join, mock_flush, def test_download_ansible_playbooks(self, mock_join, mock_stack_config,
mock_stack_config, mock_launch_heat, mock_launch_heat, mock_importInv,
mock_importInv, createdir_mock): createdir_mock):
fake_output_dir = '/twd' fake_output_dir = '/twd'
extra_vars = {'Undercloud': { extra_vars = {'Undercloud': {
@ -827,11 +826,12 @@ class TestDeployUndercloud(TestPluginV1):
'ansible_python_interpreter': sys.executable}} 'ansible_python_interpreter': sys.executable}}
mock_inventory = mock.Mock() mock_inventory = mock.Mock()
mock_importInv.return_value = mock_inventory mock_importInv.return_value = mock_inventory
self.cmd.output_dir = fake_output_dir with mock.patch('sys.stdout', autospec=True) as mock_stdout:
self.cmd._download_ansible_playbooks(mock_launch_heat, self.cmd.output_dir = fake_output_dir
'undercloud', self.cmd._download_ansible_playbooks(mock_launch_heat,
'Undercloud') 'undercloud',
self.assertEqual(mock_flush.call_count, 2) 'Undercloud')
self.assertEqual(mock_stdout.flush.call_count, 2)
mock_inventory.write_static_inventory.assert_called_once_with( mock_inventory.write_static_inventory.assert_called_once_with(
fake_output_dir + '/inventory.yaml', extra_vars) fake_output_dir + '/inventory.yaml', extra_vars)