Skip to content

Commit

Permalink
Add test mode to pydbapi method
Browse files Browse the repository at this point in the history
  • Loading branch information
arbulu89 committed Mar 23, 2020
1 parent 54fd869 commit 1b03302
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions salt/states/hanamod.py
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,12 @@ def pydbapi_extracted(
'extraction)'.format(output_dir)
return ret

if __opts__['test']:
ret['result'] = None
ret['comment'] = '{} would be extracted'.format(name)
ret['changes']['output_dir'] = output_dir
return ret

__salt__['file.mkdir'](output_dir)

try:
Expand Down
10 changes: 10 additions & 0 deletions tests/unit/states/test_hanamod.py
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,16 @@ def test_pydbapi_extracted_already_exists(self):

mock_dir_exists.assert_called_once_with('/tmp/output')

def test_pydbapi_extracted_test(self):
ret = {'name': 'PYDBAPI.tar',
'changes': {'output_dir': '/tmp/output'},
'result': None,
'comment': 'PYDBAPI.tar would be extracted'}

with patch.dict(hanamod.__opts__, {'test': True}):
assert hanamod.pydbapi_extracted(
'PYDBAPI.tar', ['1234', '5678'], '/tmp/output', force=True) == ret

def test_pydbapi_extracted_error(self):
ret = {'name': 'PYDBAPI.tar',
'changes': {},
Expand Down

0 comments on commit 1b03302

Please sign in to comment.