Browse Source

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)
changes/35/705035/2
Kevin Carter 3 weeks ago
parent
commit
fe961790f3
1 changed files with 9 additions and 9 deletions
  1. +9
    -9
      tripleoclient/tests/v1/tripleo/test_tripleo_deploy.py

+ 9
- 9
tripleoclient/tests/v1/tripleo/test_tripleo_deploy.py View File

@@ -815,11 +815,10 @@ class TestDeployUndercloud(TestPluginV1):
'_launch_heat', autospec=True)
@mock.patch('tripleo_common.utils.config.Config',
autospec=True)
@mock.patch('tripleoclient.v1.tripleo_deploy.sys.stdout.flush')
@mock.patch('os.path.join', return_value='/twd/inventory.yaml')
def test_download_ansible_playbooks(self, mock_join, mock_flush,
mock_stack_config, mock_launch_heat,
mock_importInv, createdir_mock):
def test_download_ansible_playbooks(self, mock_join, mock_stack_config,
mock_launch_heat, mock_importInv,
createdir_mock):

fake_output_dir = '/twd'
extra_vars = {'Undercloud': {
@@ -827,11 +826,12 @@ class TestDeployUndercloud(TestPluginV1):
'ansible_python_interpreter': sys.executable}}
mock_inventory = mock.Mock()
mock_importInv.return_value = mock_inventory
self.cmd.output_dir = fake_output_dir
self.cmd._download_ansible_playbooks(mock_launch_heat,
'undercloud',
'Undercloud')
self.assertEqual(mock_flush.call_count, 2)
with mock.patch('sys.stdout', autospec=True) as mock_stdout:
self.cmd.output_dir = fake_output_dir
self.cmd._download_ansible_playbooks(mock_launch_heat,
'undercloud',
'Undercloud')
self.assertEqual(mock_stdout.flush.call_count, 2)
mock_inventory.write_static_inventory.assert_called_once_with(
fake_output_dir + '/inventory.yaml', extra_vars)


Loading…
Cancel
Save