Merge "Minor tests covering unreached exec branches."

This commit is contained in:
Zuul 2021-06-09 01:05:05 +00:00 committed by Gerrit Code Review
commit 03eeaee8eb
1 changed files with 41 additions and 0 deletions

View File

@ -1870,3 +1870,44 @@ class TestGeneralUtils(base.TestCommand):
limit_hosts_expected = 'controller0:compute0:compute1:!compute2' limit_hosts_expected = 'controller0:compute0:compute1:!compute2'
limit_hosts_actual = utils.playbook_limit_parse(limit_nodes) limit_hosts_actual = utils.playbook_limit_parse(limit_nodes)
self.assertEqual(limit_hosts_actual, limit_hosts_expected) self.assertEqual(limit_hosts_actual, limit_hosts_expected)
class TestTempDirs(base.TestCase):
@mock.patch('tripleoclient.utils.tempfile.mkdtemp',
autospec=True,
return_value='foo')
@mock.patch('tripleoclient.utils.Pushd', autospec=True)
def test_init_dirpath(self, mock_pushd, mock_mkdtemp):
utils.TempDirs(dir_path='bar')
mock_pushd.assert_called_once_with(directory='foo')
mock_mkdtemp.assert_called_once_with(
dir='bar',
prefix='tripleo')
@mock.patch('tripleoclient.utils.tempfile.mkdtemp',
autospec=True,
return_value='foo')
@mock.patch('tripleoclient.utils.Pushd', autospec=True,)
def test_init_no_prefix(self, mock_pushd, mock_mkdtemp):
utils.TempDirs(dir_prefix=None)
mock_pushd.assert_called_once_with(directory='foo')
mock_mkdtemp.assert_called_once_with()
@mock.patch('tripleoclient.utils.LOG.warning', autospec=True,)
@mock.patch('tripleoclient.utils.tempfile.mkdtemp',
autospec=True,
return_value='foo')
@mock.patch('tripleoclient.utils.Pushd', autospec=True)
def test_exit_warning(self, mock_pushd, mock_mkdtemp, mock_log):
temp_dirs = utils.TempDirs(cleanup=False, chdir=False)
temp_dirs.__exit__()
mock_log.assert_called_once_with(
"Not cleaning temporary directory [ foo ]")