mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
Add 'file.source_list' mock to archive state unit tests
This commit is contained in:
parent
9064d3bbfb
commit
1fc9de1d04
@ -92,10 +92,19 @@ class ArchiveTestCase(TestCase):
|
||||
Tests the call of extraction with gnutar
|
||||
'''
|
||||
gnutar = MagicMock(return_value='tar (GNU tar)')
|
||||
source = 'GNU tar'
|
||||
missing = MagicMock(return_value=False)
|
||||
nop = MagicMock(return_value=True)
|
||||
run_all = MagicMock(return_value={'retcode': 0, 'stdout': 'stdout', 'stderr': 'stderr'})
|
||||
with patch.dict(archive.__salt__, {'cmd.run': gnutar, 'file.directory_exists': missing, 'file.file_exists': missing, 'state.single': nop, 'file.makedirs': nop, 'cmd.run_all': run_all}):
|
||||
mock_source_list = MagicMock(return_value=source)
|
||||
|
||||
with patch.dict(archive.__salt__, {'cmd.run': gnutar,
|
||||
'file.directory_exists': missing,
|
||||
'file.file_exists': missing,
|
||||
'state.single': nop,
|
||||
'file.makedirs': nop,
|
||||
'cmd.run_all': run_all,
|
||||
'file.source_list': mock_source_list}):
|
||||
ret = archive.extracted('/tmp/out', '/tmp/foo.tar.gz', 'tar', tar_options='xvzf', keep=True)
|
||||
self.assertEqual(ret['changes']['extracted_files'], 'stdout')
|
||||
|
||||
@ -104,10 +113,19 @@ class ArchiveTestCase(TestCase):
|
||||
Tests the call of extraction with bsdtar
|
||||
'''
|
||||
bsdtar = MagicMock(return_value='tar (bsdtar)')
|
||||
source = 'bsdtar'
|
||||
missing = MagicMock(return_value=False)
|
||||
nop = MagicMock(return_value=True)
|
||||
run_all = MagicMock(return_value={'retcode': 0, 'stdout': 'stdout', 'stderr': 'stderr'})
|
||||
with patch.dict(archive.__salt__, {'cmd.run': bsdtar, 'file.directory_exists': missing, 'file.file_exists': missing, 'state.single': nop, 'file.makedirs': nop, 'cmd.run_all': run_all}):
|
||||
mock_source_list = MagicMock(return_value=source)
|
||||
|
||||
with patch.dict(archive.__salt__, {'cmd.run': bsdtar,
|
||||
'file.directory_exists': missing,
|
||||
'file.file_exists': missing,
|
||||
'state.single': nop,
|
||||
'file.makedirs': nop,
|
||||
'cmd.run_all': run_all,
|
||||
'file.source_list': mock_source_list}):
|
||||
ret = archive.extracted('/tmp/out', '/tmp/foo.tar.gz', 'tar', tar_options='xvzf', keep=True)
|
||||
self.assertEqual(ret['changes']['extracted_files'], 'stderr')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user