mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Format patching with statements for easier reading
This commit is contained in:
parent
ba2f2eb788
commit
b1dfe9c3c8
1 changed files with 38 additions and 40 deletions
|
@ -102,26 +102,24 @@ class ArchiveTestCase(TestCase, LoaderModuleMockMixin):
|
|||
|
||||
with patch.dict(archive.__opts__, {'test': False,
|
||||
'cachedir': tmp_dir,
|
||||
'hash_type': 'sha256'}):
|
||||
with patch.dict(archive.__salt__, {'file.directory_exists': mock_false,
|
||||
'file.file_exists': mock_false,
|
||||
'state.single': state_single_mock,
|
||||
'file.makedirs': mock_true,
|
||||
'cmd.run_all': mock_run,
|
||||
'archive.list': list_mock,
|
||||
'file.source_list': mock_source_list}):
|
||||
with patch.dict(archive.__states__, {'file.directory': mock_true}):
|
||||
with patch.object(os.path, 'isfile', isfile_mock), \
|
||||
patch('salt.utils.which', MagicMock(return_value=True)):
|
||||
for test_opts, ret_opts in zip(test_tar_opts, ret_tar_opts):
|
||||
ret = archive.extracted(tmp_dir,
|
||||
source,
|
||||
options=test_opts,
|
||||
enforce_toplevel=False)
|
||||
ret_opts.append(source)
|
||||
mock_run.assert_called_with(ret_opts,
|
||||
cwd=tmp_dir + os.sep,
|
||||
python_shell=False)
|
||||
'hash_type': 'sha256'}),\
|
||||
patch.dict(archive.__salt__, {'file.directory_exists': mock_false,
|
||||
'file.file_exists': mock_false,
|
||||
'state.single': state_single_mock,
|
||||
'file.makedirs': mock_true,
|
||||
'cmd.run_all': mock_run,
|
||||
'archive.list': list_mock,
|
||||
'file.source_list': mock_source_list}),\
|
||||
patch.dict(archive.__states__, {'file.directory': mock_true}),\
|
||||
patch.object(os.path, 'isfile', isfile_mock),\
|
||||
patch('salt.utils.which', MagicMock(return_value=True)):
|
||||
|
||||
for test_opts, ret_opts in zip(test_tar_opts, ret_tar_opts):
|
||||
archive.extracted(tmp_dir, source, options=test_opts,
|
||||
enforce_toplevel=False)
|
||||
ret_opts.append(source)
|
||||
mock_run.assert_called_with(ret_opts, cwd=tmp_dir + os.sep,
|
||||
python_shell=False)
|
||||
|
||||
def test_tar_gnutar(self):
|
||||
'''
|
||||
|
@ -151,16 +149,16 @@ class ArchiveTestCase(TestCase, LoaderModuleMockMixin):
|
|||
'file.makedirs': mock_true,
|
||||
'cmd.run_all': run_all,
|
||||
'archive.list': list_mock,
|
||||
'file.source_list': mock_source_list}):
|
||||
with patch.dict(archive.__states__, {'file.directory': mock_true}):
|
||||
with patch.object(os.path, 'isfile', isfile_mock), \
|
||||
patch('salt.utils.which', MagicMock(return_value=True)):
|
||||
ret = archive.extracted(os.path.join(os.sep + 'tmp', 'out'),
|
||||
source,
|
||||
options='xvzf',
|
||||
enforce_toplevel=False,
|
||||
keep=True)
|
||||
self.assertEqual(ret['changes']['extracted_files'], 'stdout')
|
||||
'file.source_list': mock_source_list}),\
|
||||
patch.dict(archive.__states__, {'file.directory': mock_true}),\
|
||||
patch.object(os.path, 'isfile', isfile_mock),\
|
||||
patch('salt.utils.which', MagicMock(return_value=True)):
|
||||
ret = archive.extracted(os.path.join(os.sep + 'tmp', 'out'),
|
||||
source,
|
||||
options='xvzf',
|
||||
enforce_toplevel=False,
|
||||
keep=True)
|
||||
self.assertEqual(ret['changes']['extracted_files'], 'stdout')
|
||||
|
||||
def test_tar_bsdtar(self):
|
||||
'''
|
||||
|
@ -190,13 +188,13 @@ class ArchiveTestCase(TestCase, LoaderModuleMockMixin):
|
|||
'file.makedirs': mock_true,
|
||||
'cmd.run_all': run_all,
|
||||
'archive.list': list_mock,
|
||||
'file.source_list': mock_source_list}):
|
||||
with patch.dict(archive.__states__, {'file.directory': mock_true}):
|
||||
with patch.object(os.path, 'isfile', isfile_mock), \
|
||||
patch('salt.utils.which', MagicMock(return_value=True)):
|
||||
ret = archive.extracted(os.path.join(os.sep + 'tmp', 'out'),
|
||||
source,
|
||||
options='xvzf',
|
||||
enforce_toplevel=False,
|
||||
keep=True)
|
||||
self.assertEqual(ret['changes']['extracted_files'], 'stderr')
|
||||
'file.source_list': mock_source_list}),\
|
||||
patch.dict(archive.__states__, {'file.directory': mock_true}),\
|
||||
patch.object(os.path, 'isfile', isfile_mock),\
|
||||
patch('salt.utils.which', MagicMock(return_value=True)):
|
||||
ret = archive.extracted(os.path.join(os.sep + 'tmp', 'out'),
|
||||
source,
|
||||
options='xvzf',
|
||||
enforce_toplevel=False,
|
||||
keep=True)
|
||||
self.assertEqual(ret['changes']['extracted_files'], 'stderr')
|
||||
|
|
Loading…
Add table
Reference in a new issue