desc
stringlengths 3
26.7k
| decl
stringlengths 11
7.89k
| bodies
stringlengths 8
553k
|
---|---|---|
'cp.list_states'
| def test_list_states(self):
| ret = self.run_function('cp.list_states')
self.assertIn('core', ret)
self.assertIn('top', ret)
|
'cp.list_minion'
| def test_list_minion(self):
| self.run_function('cp.cache_file', ['salt://grail/scene33'])
ret = self.run_function('cp.list_minion')
found = False
search = 'grail/scene33'
if salt.utils.platform.is_windows():
search = 'grail\\scene33'
for path in ret:
if (search in path):
found = True
break
self.assertTrue(found)
|
'cp.is_cached'
| def test_is_cached(self):
| self.run_function('cp.cache_file', ['salt://grail/scene33'])
ret1 = self.run_function('cp.is_cached', ['salt://grail/scene33'])
self.assertTrue(ret1)
ret2 = self.run_function('cp.is_cached', ['salt://fasldkgj/poicxzbn'])
self.assertFalse(ret2)
|
'cp.hash_file'
| def test_hash_file(self):
| sha256_hash = self.run_function('cp.hash_file', ['salt://grail/scene33'])
path = self.run_function('cp.cache_file', ['salt://grail/scene33'])
with salt.utils.files.fopen(path, 'r') as fn_:
data = fn_.read()
if six.PY3:
data = salt.utils.stringutils.to_bytes(data)
self.assertEqual(sha256_hash['hsum'], hashlib.sha256(data).hexdigest())
|
'cp.get_file'
| def test_get_file_from_env_predefined(self):
| tgt = os.path.join(paths.TMP, 'cheese')
try:
self.run_function('cp.get_file', ['salt://cheese', tgt])
with salt.utils.files.fopen(tgt, 'r') as cheese:
data = cheese.read()
self.assertIn('Gromit', data)
self.assertNotIn('Comte', data)
finally:
os.unlink(tgt)
|
'virtualenv.managed'
| def test_create_defaults(self):
| self.run_function('virtualenv.create', [self.venv_dir])
pip_file = os.path.join(self.venv_dir, 'bin', 'pip')
self.assertTrue(os.path.exists(pip_file))
|
'Make sure no functions are exposed that don\'t have valid docstrings'
| def test_valid_docs(self):
| ret = self.run_function('runtests_helpers.get_invalid_docs')
if (ret == {'missing_docstring': [], 'missing_cli_example': []}):
return
raise AssertionError('There are some functions which do not have a docstring or do not have an example:\nNo docstring:\n{0}\nNo example:\n{1}\n'.format('\n'.join([' - {0}'.format(f) for f in ret['missing_docstring']]), '\n'.join([' - {0}'.format(f) for f in ret['missing_cli_example']])))
|
'state.show_highstate'
| def test_show_highstate(self):
| high = self.run_function('state.show_highstate')
destpath = os.path.join(TMP, 'testfile')
self.assertTrue(isinstance(high, dict))
self.assertTrue((destpath in high))
self.assertEqual(high[destpath]['__env__'], 'base')
|
'state.show_lowstate'
| def test_show_lowstate(self):
| low = self.run_function('state.show_lowstate')
self.assertTrue(isinstance(low, list))
self.assertTrue(isinstance(low[0], dict))
|
'state.show_sls used to catch a recursive ref'
| def test_catch_recurse(self):
| err = self.run_function('state.sls', mods='recurse_fail')
self.assertIn('recursive', err[0])
|
'verify that a sls structure is NOT a recursive ref'
| def test_no_recurse(self):
| sls = self.run_function('state.show_sls', mods='recurse_ok')
self.assertIn('snmpd', sls)
|
'verify that a sls structure is NOT a recursive ref'
| def test_no_recurse_two(self):
| sls = self.run_function('state.show_sls', mods='recurse_ok_two')
self.assertIn('/etc/nagios/nrpe.cfg', sls)
|
'Test the structure of the running dictionary so we don\'t change it
without deprecating/documenting the change'
| def test_running_dictionary_consistency(self):
| running_dict_fields = ['__id__', '__run_num__', '__sls__', 'changes', 'comment', 'duration', 'name', 'result', 'start_time']
sls = self.run_function('state.single', fun='test.succeed_with_changes', name='gndn')
for (state, ret) in sls.items():
for field in running_dict_fields:
self.assertIn(field, ret)
|
'Ensure the __sls__ key is either null or a string'
| def test_running_dictionary_key_sls(self):
| sls1 = self.run_function('state.single', fun='test.succeed_with_changes', name='gndn')
sls2 = self.run_function('state.sls', mods='gndn')
for (state, ret) in sls1.items():
self.assertTrue(isinstance(ret['__sls__'], type(None)))
for (state, ret) in sls2.items():
self.assertTrue(isinstance(ret['__sls__'], six.string_types))
|
'remove minion state request file'
| def _remove_request_cache_file(self):
| cache_file = os.path.join(self.get_config('minion')['cachedir'], 'req_state.p')
if os.path.exists(cache_file):
os.remove(cache_file)
|
'verify sending a state request to the minion(s)'
| def test_request(self):
| self._remove_request_cache_file()
ret = self.run_function('state.request', mods='modules.state.requested')
result = ret['cmd_|-count_root_dir_contents_|-ls -a / | wc -l_|-run']['result']
self.assertEqual(result, None)
|
'verify checking a state request sent to the minion(s)'
| def test_check_request(self):
| self._remove_request_cache_file()
self.run_function('state.request', mods='modules.state.requested')
ret = self.run_function('state.check_request')
result = ret['default']['test_run']['cmd_|-count_root_dir_contents_|-ls -a / | wc -l_|-run']['result']
self.assertEqual(result, None)
|
'verify clearing a state request sent to the minion(s)'
| def test_clear_request(self):
| self._remove_request_cache_file()
self.run_function('state.request', mods='modules.state.requested')
ret = self.run_function('state.clear_request')
self.assertTrue(ret)
|
'verify running a state request sent to the minion(s)'
| def test_run_request_succeeded(self):
| self._remove_request_cache_file()
if salt.utils.platform.is_windows():
self.run_function('state.request', mods='modules.state.requested_win')
else:
self.run_function('state.request', mods='modules.state.requested')
ret = self.run_function('state.run_request')
if salt.utils.platform.is_windows():
key = 'cmd_|-count_root_dir_contents_|-Get-ChildItem C:\\\\ | Measure-Object | %{$_.Count}_|-run'
else:
key = 'cmd_|-count_root_dir_contents_|-ls -a / | wc -l_|-run'
result = ret[key]['result']
self.assertTrue(result)
|
'verify not running a state request sent to the minion(s)'
| def test_run_request_failed_no_request_staged(self):
| self._remove_request_cache_file()
self.run_function('state.request', mods='modules.state.requested')
self.run_function('state.clear_request')
ret = self.run_function('state.run_request')
self.assertEqual(ret, {})
|
'Verify that we can append a file\'s contents'
| def test_issue_1896_file_append_source(self):
| testfile = os.path.join(TMP, 'test.append')
if os.path.isfile(testfile):
os.unlink(testfile)
ret = self.run_function('state.sls', mods='testappend')
self.assertSaltTrueReturn(ret)
ret = self.run_function('state.sls', mods='testappend.step-1')
self.assertSaltTrueReturn(ret)
ret = self.run_function('state.sls', mods='testappend.step-2')
self.assertSaltTrueReturn(ret)
with salt.utils.files.fopen(testfile, 'r') as fp_:
testfile_contents = fp_.read()
contents = textwrap.dedent(' # set variable identifying the chroot you work in (used in the prompt below)\n if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then\n debian_chroot=$(cat /etc/debian_chroot)\n fi\n ')
if (not salt.utils.platform.is_windows()):
contents += os.linesep
contents += textwrap.dedent(' # enable bash completion in interactive shells\n if [ -f /etc/bash_completion ] && ! shopt -oq posix; then\n . /etc/bash_completion\n fi\n ')
if salt.utils.platform.is_windows():
new_contents = contents.splitlines()
contents = os.linesep.join(new_contents)
contents += os.linesep
self.assertMultiLineEqual(contents, testfile_contents)
ret = self.run_function('state.sls', mods='testappend.step-2')
self.assertSaltTrueReturn(ret)
ret = self.run_function('state.sls', mods='testappend.step-1')
self.assertSaltTrueReturn(ret)
with salt.utils.files.fopen(testfile, 'r') as fp_:
testfile_contents = fp_.read()
self.assertMultiLineEqual(contents, testfile_contents)
|
'verify that we catch the following syntax error::
/tmp/salttest/issue-1876:
file:
- managed
- source: salt://testfile
file.append:
- text: foo'
| def test_issue_1876_syntax_error(self):
| testfile = os.path.join(TMP, 'issue-1876')
sls = self.run_function('state.sls', mods='issue-1876')
self.assertIn("ID '{0}' in SLS 'issue-1876' contains multiple state declarations of the same type".format(testfile), sls)
|
'Test the basics of the pydsl'
| def test_pydsl(self):
| ret = self.run_function('state.sls', mods='pydsl-1')
self.assertSaltTrueReturn(ret)
|
'Call sls file with yaml syntax error.
Ensure theses errors are detected and presented to the user without
stack traces.'
| def test_issues_7905_and_8174_sls_syntax_error(self):
| ret = self.run_function('state.sls', mods='syntax.badlist')
self.assertEqual(ret, ["State 'A' in SLS 'syntax.badlist' is not formed as a list"])
ret = self.run_function('state.sls', mods='syntax.badlist2')
self.assertEqual(ret, ["State 'C' in SLS 'syntax.badlist2' is not formed as a list"])
|
'Call sls file containing several requisites.'
| def test_requisites_mixed_require_prereq_use(self):
| expected_simple_result = {'cmd_|-A_|-echo A_|-run': {'__run_num__': 2, 'comment': 'Command "echo A" run', 'result': True, 'changes': True}, 'cmd_|-B_|-echo B_|-run': {'__run_num__': 1, 'comment': 'Command "echo B" run', 'result': True, 'changes': True}, 'cmd_|-C_|-echo C_|-run': {'__run_num__': 0, 'comment': 'Command "echo C" run', 'result': True, 'changes': True}}
expected_result = {'cmd_|-A_|-echo A fifth_|-run': {'__run_num__': 4, 'comment': 'Command "echo A fifth" run', 'result': True, 'changes': True}, 'cmd_|-B_|-echo B third_|-run': {'__run_num__': 2, 'comment': 'Command "echo B third" run', 'result': True, 'changes': True}, 'cmd_|-C_|-echo C second_|-run': {'__run_num__': 1, 'comment': 'Command "echo C second" run', 'result': True, 'changes': True}, 'cmd_|-D_|-echo D first_|-run': {'__run_num__': 0, 'comment': 'Command "echo D first" run', 'result': True, 'changes': True}, 'cmd_|-E_|-echo E fourth_|-run': {'__run_num__': 3, 'comment': 'Command "echo E fourth" run', 'result': True, 'changes': True}}
expected_req_use_result = {'cmd_|-A_|-echo A_|-run': {'__run_num__': 1, 'comment': 'Command "echo A" run', 'result': True, 'changes': True}, 'cmd_|-B_|-echo B_|-run': {'__run_num__': 4, 'comment': 'Command "echo B" run', 'result': True, 'changes': True}, 'cmd_|-C_|-echo C_|-run': {'__run_num__': 0, 'comment': 'Command "echo C" run', 'result': True, 'changes': True}, 'cmd_|-D_|-echo D_|-run': {'__run_num__': 5, 'comment': 'Command "echo D" run', 'result': True, 'changes': True}, 'cmd_|-E_|-echo E_|-run': {'__run_num__': 2, 'comment': 'Command "echo E" run', 'result': True, 'changes': True}, 'cmd_|-F_|-echo F_|-run': {'__run_num__': 3, 'comment': 'Command "echo F" run', 'result': True, 'changes': True}}
ret = self.run_function('state.sls', mods='requisites.mixed_simple')
result = self.normalize_ret(ret)
self.assertReturnNonEmptySaltType(ret)
self.assertEqual(expected_simple_result, result)
|
'Normalize the return to the format that we\'ll use for result checking'
| def normalize_ret(self, ret):
| result = {}
for (item, descr) in six.iteritems(ret):
result[item] = {'__run_num__': descr['__run_num__'], 'comment': descr['comment'], 'result': descr['result'], 'changes': (descr['changes'] != {})}
return result
|
'Call sls file containing several require_in and require.
Ensure that some of them are failing and that the order is right.'
| def test_requisites_require_ordering_and_errors(self):
| expected_result = {'cmd_|-A_|-echo A fifth_|-run': {'__run_num__': 4, 'comment': 'Command "echo A fifth" run', 'result': True, 'changes': True}, 'cmd_|-B_|-echo B second_|-run': {'__run_num__': 1, 'comment': 'Command "echo B second" run', 'result': True, 'changes': True}, 'cmd_|-C_|-echo C third_|-run': {'__run_num__': 2, 'comment': 'Command "echo C third" run', 'result': True, 'changes': True}, 'cmd_|-D_|-echo D first_|-run': {'__run_num__': 0, 'comment': 'Command "echo D first" run', 'result': True, 'changes': True}, 'cmd_|-E_|-echo E fourth_|-run': {'__run_num__': 3, 'comment': 'Command "echo E fourth" run', 'result': True, 'changes': True}, 'cmd_|-F_|-echo F_|-run': {'__run_num__': 5, 'comment': (('The following requisites were not found:\n' + ' require:\n') + ' foobar: A\n'), 'result': False, 'changes': False}, 'cmd_|-G_|-echo G_|-run': {'__run_num__': 6, 'comment': (('The following requisites were not found:\n' + ' require:\n') + ' cmd: Z\n'), 'result': False, 'changes': False}, 'cmd_|-H_|-echo H_|-run': {'__run_num__': 7, 'comment': (('The following requisites were not found:\n' + ' require:\n') + ' cmd: Z\n'), 'result': False, 'changes': False}}
ret = self.run_function('state.sls', mods='requisites.require')
result = self.normalize_ret(ret)
self.assertReturnNonEmptySaltType(ret)
self.assertEqual(expected_result, result)
ret = self.run_function('state.sls', mods='requisites.require_error1')
self.assertEqual(ret, ["Cannot extend ID 'W' in 'base:requisites.require_error1'. It is not part of the high state.\nThis is likely due to a missing include statement or an incorrectly typed ID.\nEnsure that a state with an ID of 'W' is available\nin environment 'base' and to SLS 'requisites.require_error1'"])
result = {}
ret = self.run_function('state.sls', mods='requisites.require_simple_nolist')
self.assertEqual(ret, [("The require statement in state 'B' in SLS " + "'requisites.require_simple_nolist' needs to be formed as a list")])
ret = self.run_function('state.sls', mods='requisites.require_recursion_error1')
self.assertEqual(ret, ['A recursive requisite was found, SLS "requisites.require_recursion_error1" ID "B" ID "A"'])
|
'Teste the sls special command in requisites'
| def test_requisites_full_sls(self):
| expected_result = {'cmd_|-A_|-echo A_|-run': {'__run_num__': 2, 'comment': 'Command "echo A" run', 'result': True, 'changes': True}, 'cmd_|-B_|-echo B_|-run': {'__run_num__': 0, 'comment': 'Command "echo B" run', 'result': True, 'changes': True}, 'cmd_|-C_|-echo C_|-run': {'__run_num__': 1, 'comment': 'Command "echo C" run', 'result': True, 'changes': True}}
ret = self.run_function('state.sls', mods='requisites.fullsls_require')
self.assertReturnNonEmptySaltType(ret)
result = self.normalize_ret(ret)
self.assertEqual(expected_result, result)
|
'Call sls file containing several prereq_in and prereq.
Ensure that some of them are failing and that the order is right.'
| def test_requisites_prereq_simple_ordering_and_errors(self):
| expected_result_simple = {'cmd_|-A_|-echo A third_|-run': {'__run_num__': 2, 'comment': 'Command "echo A third" run', 'result': True, 'changes': True}, 'cmd_|-B_|-echo B first_|-run': {'__run_num__': 0, 'comment': 'Command "echo B first" run', 'result': True, 'changes': True}, 'cmd_|-C_|-echo C second_|-run': {'__run_num__': 1, 'comment': 'Command "echo C second" run', 'result': True, 'changes': True}, 'cmd_|-I_|-echo I_|-run': {'__run_num__': 3, 'comment': (('The following requisites were not found:\n' + ' prereq:\n') + ' cmd: Z\n'), 'result': False, 'changes': False}, 'cmd_|-J_|-echo J_|-run': {'__run_num__': 4, 'comment': (('The following requisites were not found:\n' + ' prereq:\n') + ' foobar: A\n'), 'result': False, 'changes': False}}
expected_result_simple2 = {'cmd_|-A_|-echo A_|-run': {'__run_num__': 1, 'comment': 'Command "echo A" run', 'result': True, 'changes': True}, 'cmd_|-B_|-echo B_|-run': {'__run_num__': 2, 'comment': 'Command "echo B" run', 'result': True, 'changes': True}, 'cmd_|-C_|-echo C_|-run': {'__run_num__': 0, 'comment': 'Command "echo C" run', 'result': True, 'changes': True}, 'cmd_|-D_|-echo D_|-run': {'__run_num__': 3, 'comment': 'Command "echo D" run', 'result': True, 'changes': True}, 'cmd_|-E_|-echo E_|-run': {'__run_num__': 4, 'comment': 'Command "echo E" run', 'result': True, 'changes': True}}
expected_result_simple3 = {'cmd_|-A_|-echo A first_|-run': {'__run_num__': 0, 'comment': 'Command "echo A first" run', 'result': True, 'changes': True}, 'cmd_|-B_|-echo B second_|-run': {'__run_num__': 1, 'comment': 'Command "echo B second" run', 'result': True, 'changes': True}, 'cmd_|-C_|-echo C third_|-wait': {'__run_num__': 2, 'comment': '', 'result': True, 'changes': False}}
expected_result_complex = {'cmd_|-A_|-echo A fourth_|-run': {'__run_num__': 3, 'comment': 'Command "echo A fourth" run', 'result': True, 'changes': True}, 'cmd_|-B_|-echo B first_|-run': {'__run_num__': 0, 'comment': 'Command "echo B first" run', 'result': True, 'changes': True}, 'cmd_|-C_|-echo C second_|-run': {'__run_num__': 1, 'comment': 'Command "echo C second" run', 'result': True, 'changes': True}, 'cmd_|-D_|-echo D third_|-run': {'__run_num__': 2, 'comment': 'Command "echo D third" run', 'result': True, 'changes': True}}
ret = self.run_function('state.sls', mods='requisites.prereq_simple')
self.assertReturnNonEmptySaltType(ret)
result = self.normalize_ret(ret)
self.assertEqual(expected_result_simple, result)
ret = self.run_function('state.sls', mods='requisites.prereq_simple2')
result = self.normalize_ret(ret)
self.assertReturnNonEmptySaltType(ret)
self.assertEqual(expected_result_simple2, result)
ret = self.run_function('state.sls', mods='requisites.prereq_simple3')
result = self.normalize_ret(ret)
self.assertReturnNonEmptySaltType(ret)
self.assertEqual(expected_result_simple3, result)
ret = self.run_function('state.sls', mods='requisites.prereq_compile_error1')
self.assertReturnNonEmptySaltType(ret)
self.assertEqual(ret['cmd_|-B_|-echo B_|-run']['comment'], (('The following requisites were not found:\n' + ' prereq:\n') + ' foobar: A\n'))
ret = self.run_function('state.sls', mods='requisites.prereq_compile_error2')
self.assertReturnNonEmptySaltType(ret)
self.assertEqual(ret['cmd_|-B_|-echo B_|-run']['comment'], (('The following requisites were not found:\n' + ' prereq:\n') + ' foobar: C\n'))
ret = self.run_function('state.sls', mods='requisites.prereq_complex')
result = self.normalize_ret(ret)
self.assertEqual(expected_result_complex, result)
|
'Call sls file containing several use_in and use.'
| def test_requisites_use(self):
| ret = self.run_function('state.sls', mods='requisites.use')
self.assertReturnNonEmptySaltType(ret)
for (item, descr) in six.iteritems(ret):
self.assertEqual(descr['comment'], 'onlyif execution failed')
|
'Tests a simple state using the onchanges requisite'
| def test_onchanges_requisite(self):
| state_run = self.run_function('state.sls', mods='requisites.onchanges_simple')
test_data = state_run['cmd_|-test_changing_state_|-echo "Success!"_|-run']['comment']
expected_result = 'Command "echo "Success!"" run'
self.assertIn(expected_result, test_data)
test_data = state_run['cmd_|-test_non_changing_state_|-echo "Should not run"_|-run']['comment']
expected_result = 'State was not run because none of the onchanges reqs changed'
self.assertIn(expected_result, test_data)
|
'Tests a simple state using the onchanges requisite'
| def test_onchanges_requisite_multiple(self):
| state_run = self.run_function('state.sls', mods='requisites.onchanges_multiple')
test_data = state_run['cmd_|-test_two_changing_states_|-echo "Success!"_|-run']['comment']
expected_result = 'Command "echo "Success!"" run'
self.assertIn(expected_result, test_data)
test_data = state_run['cmd_|-test_two_non_changing_states_|-echo "Should not run"_|-run']['comment']
expected_result = 'State was not run because none of the onchanges reqs changed'
self.assertIn(expected_result, test_data)
test_data = state_run['cmd_|-test_one_changing_state_|-echo "Success!"_|-run']['comment']
expected_result = 'Command "echo "Success!"" run'
self.assertIn(expected_result, test_data)
|
'Tests a simple state using the onchanges_in requisite'
| def test_onchanges_in_requisite(self):
| state_run = self.run_function('state.sls', mods='requisites.onchanges_in_simple')
test_data = state_run['cmd_|-test_changes_expected_|-echo "Success!"_|-run']['comment']
expected_result = 'Command "echo "Success!"" run'
self.assertIn(expected_result, test_data)
test_data = state_run['cmd_|-test_changes_not_expected_|-echo "Should not run"_|-run']['comment']
expected_result = 'State was not run because none of the onchanges reqs changed'
self.assertIn(expected_result, test_data)
|
'Tests a simple state using the onfail requisite'
| def test_onfail_requisite(self):
| state_run = self.run_function('state.sls', mods='requisites.onfail_simple')
test_data = state_run['cmd_|-test_failing_state_|-echo "Success!"_|-run']['comment']
expected_result = 'Command "echo "Success!"" run'
self.assertIn(expected_result, test_data)
test_data = state_run['cmd_|-test_non_failing_state_|-echo "Should not run"_|-run']['comment']
expected_result = 'State was not run because onfail req did not change'
self.assertIn(expected_result, test_data)
|
'test to ensure state is run even if only one
of the onfails fails. This is a test for the issue:
https://github.com/saltstack/salt/issues/22370'
| def test_multiple_onfail_requisite(self):
| state_run = self.run_function('state.sls', mods='requisites.onfail_multiple')
retcode = state_run['cmd_|-c_|-echo itworked_|-run']['changes']['retcode']
self.assertEqual(retcode, 0)
stdout = state_run['cmd_|-c_|-echo itworked_|-run']['changes']['stdout']
self.assertEqual(stdout, 'itworked')
|
'Tests a simple state using the onfail_in requisite'
| def test_onfail_in_requisite(self):
| state_run = self.run_function('state.sls', mods='requisites.onfail_in_simple')
test_data = state_run['cmd_|-test_failing_state_|-echo "Success!"_|-run']['comment']
expected_result = 'Command "echo "Success!"" run'
self.assertIn(expected_result, test_data)
test_data = state_run['cmd_|-test_non_failing_state_|-echo "Should not run"_|-run']['comment']
expected_result = 'State was not run because onfail req did not change'
self.assertIn(expected_result, test_data)
|
'Tests a simple state using the listen requisite'
| def test_listen_requisite(self):
| state_run = self.run_function('state.sls', mods='requisites.listen_simple')
listener_state = 'cmd_|-listener_test_listening_change_state_|-echo "Listening State"_|-mod_watch'
self.assertIn(listener_state, state_run)
absent_state = 'cmd_|-listener_test_listening_non_changing_state_|-echo "Only run once"_|-mod_watch'
self.assertNotIn(absent_state, state_run)
|
'Tests a simple state using the listen_in requisite'
| def test_listen_in_requisite(self):
| state_run = self.run_function('state.sls', mods='requisites.listen_in_simple')
listener_state = 'cmd_|-listener_test_listening_change_state_|-echo "Listening State"_|-mod_watch'
self.assertIn(listener_state, state_run)
absent_state = 'cmd_|-listener_test_listening_non_changing_state_|-echo "Only run once"_|-mod_watch'
self.assertNotIn(absent_state, state_run)
|
'Verify listen_in requisite lookups use ID declaration to check for changes'
| def test_listen_in_requisite_resolution(self):
| state_run = self.run_function('state.sls', mods='requisites.listen_in_simple')
listener_state = 'cmd_|-listener_test_listen_in_resolution_|-echo "Successful listen_in resolution"_|-mod_watch'
self.assertIn(listener_state, state_run)
|
'Verify listen requisite lookups use ID declaration to check for changes'
| def test_listen_requisite_resolution(self):
| state_run = self.run_function('state.sls', mods='requisites.listen_simple')
listener_state = 'cmd_|-listener_test_listening_resolution_one_|-echo "Successful listen resolution"_|-mod_watch'
self.assertIn(listener_state, state_run)
listener_state = 'cmd_|-listener_test_listening_resolution_two_|-echo "Successful listen resolution"_|-mod_watch'
self.assertIn(listener_state, state_run)
|
'This tests the case where a requisite_in matches by name instead of ID
See https://github.com/saltstack/salt/issues/30820 for more info'
| def test_issue_30820_requisite_in_match_by_name(self):
| state_run = self.run_function('state.sls', mods='requisites.requisite_in_match_by_name')
bar_state = 'cmd_|-bar state_|-echo bar_|-wait'
self.assertIn(bar_state, state_run)
self.assertEqual(state_run[bar_state]['comment'], 'Command "echo bar" run')
|
'test the retry option on a simple state with defaults
ensure comment is as expected
ensure state duration is greater than default retry_interval (30 seconds)'
| def test_retry_option_defaults(self):
| state_run = self.run_function('state.sls', mods='retry.retry_defaults')
retry_state = 'file_|-file_test_|-/path/to/a/non-existent/file.txt_|-exists'
expected_comment = 'Attempt 1: Returned a result of "False", with the following comment: "Specified path /path/to/a/non-existent/file.txt does not exist"\nSpecified path /path/to/a/non-existent/file.txt does not exist'
self.assertEqual(state_run[retry_state]['comment'], expected_comment)
self.assertTrue((state_run[retry_state]['duration'] > 30))
self.assertEqual(state_run[retry_state]['result'], False)
|
'test the retry option on a simple state with custom retry values
ensure comment is as expected
ensure state duration is greater than custom defined interval * (retries - 1)'
| def test_retry_option_custom(self):
| state_run = self.run_function('state.sls', mods='retry.retry_custom')
retry_state = 'file_|-file_test_|-/path/to/a/non-existent/file.txt_|-exists'
expected_comment = 'Attempt 1: Returned a result of "False", with the following comment: "Specified path /path/to/a/non-existent/file.txt does not exist"\nAttempt 2: Returned a result of "False", with the following comment: "Specified path /path/to/a/non-existent/file.txt does not exist"\nAttempt 3: Returned a result of "False", with the following comment: "Specified path /path/to/a/non-existent/file.txt does not exist"\nAttempt 4: Returned a result of "False", with the following comment: "Specified path /path/to/a/non-existent/file.txt does not exist"\nSpecified path /path/to/a/non-existent/file.txt does not exist'
self.assertEqual(state_run[retry_state]['comment'], expected_comment)
self.assertTrue((state_run[retry_state]['duration'] > 40))
self.assertEqual(state_run[retry_state]['result'], False)
|
'test a state with the retry option that should return True immedietly (i.e. no retries)'
| def test_retry_option_success(self):
| testfile = os.path.join(TMP, 'retry_file')
state_run = self.run_function('state.sls', mods='retry.retry_success')
os.unlink(testfile)
retry_state = 'file_|-file_test_|-{0}_|-exists'.format(testfile)
self.assertNotIn('Attempt', state_run[retry_state]['comment'])
|
'helper function to wait 30 seconds and then create the temp retry file'
| def run_create(self):
| testfile = os.path.join(TMP, 'retry_file')
time.sleep(30)
open(testfile, 'a').close()
|
'test a state with the retry option that should return True after at least 4 retry attmempt
but never run 15 attempts'
| def test_retry_option_eventual_success(self):
| testfile = os.path.join(TMP, 'retry_file')
create_thread = threading.Thread(target=self.run_create)
create_thread.start()
state_run = self.run_function('state.sls', mods='retry.retry_success2')
retry_state = 'file_|-file_test_|-{0}_|-exists'.format(testfile)
self.assertIn('Attempt 1:', state_run[retry_state]['comment'])
self.assertIn('Attempt 2:', state_run[retry_state]['comment'])
self.assertIn('Attempt 3:', state_run[retry_state]['comment'])
self.assertIn('Attempt 4:', state_run[retry_state]['comment'])
self.assertNotIn('Attempt 15:', state_run[retry_state]['comment'])
self.assertEqual(state_run[retry_state]['result'], True)
|
'This tests the case where require, order, and failhard are all used together in a state definition.
Previously, the order option, which used in tandem with require and failhard, would cause the state
compiler to stacktrace. This exposed a logic error in the ``check_failhard`` function of the state
compiler. With the logic error resolved, this test should now pass.
See https://github.com/saltstack/salt/issues/38683 for more information.'
| def test_issue_38683_require_order_failhard_combination(self):
| state_run = self.run_function('state.sls', mods='requisites.require_order_failhard_combo')
state_id = 'test_|-b_|-b_|-fail_with_changes'
self.assertIn(state_id, state_run)
self.assertEqual(state_run[state_id]['comment'], 'Failure!')
self.assertFalse(state_run[state_id]['result'])
|
'Get current settings'
| def setUp(self):
| if (not salt.utils.platform.is_darwin()):
self.skipTest('Test only available on macOS')
if (not salt.utils.path.which('port')):
self.skipTest('Test requires port binary')
self.AGREE_INSTALLED = ('agree' in self.run_function('pkg.list_pkgs'))
self.run_function('pkg.refresh_db')
|
'Reset to original settings'
| def tearDown(self):
| if (not self.AGREE_INSTALLED):
self.run_function('pkg.remove', ['agree'])
|
'Test pkg.list_pkgs'
| @destructiveTest
def test_list_pkgs(self):
| self.run_function('pkg.install', ['agree'])
self.assertIsInstance(self.run_function('pkg.list_pkgs'), dict)
self.assertIn('agree', self.run_function('pkg.list_pkgs'))
|
'Test pkg.latest_version'
| @destructiveTest
def test_latest_version(self):
| self.run_function('pkg.install', ['agree'])
result = self.run_function('pkg.latest_version', ['agree'], refresh=False)
self.assertIsInstance(result, dict)
self.assertIn('agree', result)
|
'Test pkg.remove'
| @destructiveTest
def test_remove(self):
| self.run_function('pkg.install', ['agree'])
removed = self.run_function('pkg.remove', ['agree'])
self.assertIsInstance(removed, dict)
self.assertIn('agree', removed)
|
'Test pkg.install'
| @destructiveTest
def test_install(self):
| self.run_function('pkg.remove', ['agree'])
installed = self.run_function('pkg.install', ['agree'])
self.assertIsInstance(installed, dict)
self.assertIn('agree', installed)
|
'Test pkg.list_upgrades'
| def test_list_upgrades(self):
| self.assertIsInstance(self.run_function('pkg.list_upgrades', refresh=False), dict)
|
'Test pkg.upgrade_available'
| @destructiveTest
def test_upgrade_available(self):
| self.run_function('pkg.install', ['agree'])
self.assertFalse(self.run_function('pkg.upgrade_available', ['agree'], refresh=False))
|
'Test pkg.refresh_db'
| def test_refresh_db(self):
| self.assertTrue(self.run_function('pkg.refresh_db'))
|
'Test pkg.upgrade'
| @destructiveTest
def test_upgrade(self):
| results = self.run_function('pkg.upgrade', refresh=False)
self.assertIsInstance(results, dict)
self.assertTrue(results['result'])
|
'Test virt.get_profiles with the KVM profile'
| def test_default_kvm_profile(self):
| profiles = self.run_function('virt.get_profiles', ['kvm'])
nicp = profiles['nic']['default']
self.assertTrue((nicp[0].get('model', '') == 'virtio'))
self.assertTrue((nicp[0].get('source', '') == 'br0'))
diskp = profiles['disk']['default']
self.assertTrue((diskp[0]['system'].get('model', '') == 'virtio'))
self.assertTrue((diskp[0]['system'].get('format', '') == 'qcow2'))
self.assertTrue((diskp[0]['system'].get('size', '') == '8192'))
|
'Test virt.get_profiles with the ESX profile'
| def test_default_esxi_profile(self):
| profiles = self.run_function('virt.get_profiles', ['esxi'])
nicp = profiles['nic']['default']
self.assertTrue((nicp[0].get('model', '') == 'e1000'))
self.assertTrue((nicp[0].get('source', '') == 'DEFAULT'))
diskp = profiles['disk']['default']
self.assertTrue((diskp[0]['system'].get('model', '') == 'scsi'))
self.assertTrue((diskp[0]['system'].get('format', '') == 'vmdk'))
self.assertTrue((diskp[0]['system'].get('size', '') == '8192'))
|
'Sets up the test requirements'
| def setUp(self):
| os_grain = self.run_function('grains.item', ['kernel'])
if (os_grain['kernel'] not in 'Darwin'):
self.skipTest("Test not applicable to '{kernel}' kernel".format(**os_grain))
|
'Clean up after tests'
| def tearDown(self):
| certs_list = self.run_function('keychain.list_certs')
if (CERT_ALIAS in certs_list):
self.run_function('keychain.uninstall', [CERT_ALIAS])
|
'Tests that attempts to install a certificate'
| def test_mac_keychain_install(self):
| install_cert = self.run_function('keychain.install', [CERT, PASSWD])
self.assertTrue(install_cert)
certs_list = self.run_function('keychain.list_certs')
self.assertIn(CERT_ALIAS, certs_list)
|
'Tests that attempts to uninstall a certificate'
| def test_mac_keychain_uninstall(self):
| self.run_function('keychain.install', [CERT, PASSWD])
certs_list = self.run_function('keychain.list_certs')
if (CERT_ALIAS not in certs_list):
self.run_function('keychain.uninstall', [CERT_ALIAS])
self.skipTest('Failed to install keychain')
self.run_function('keychain.uninstall', [CERT_ALIAS])
certs_list = self.run_function('keychain.list_certs')
try:
self.assertNotIn(CERT_ALIAS, str(certs_list))
except CommandExecutionError:
self.run_function('keychain.uninstall', [CERT_ALIAS])
|
'Test that attempts to get friendly name of a cert'
| def test_mac_keychain_get_friendly_name(self):
| self.run_function('keychain.install', [CERT, PASSWD])
certs_list = self.run_function('keychain.list_certs')
if (CERT_ALIAS not in certs_list):
self.run_function('keychain.uninstall', [CERT_ALIAS])
self.skipTest('Failed to install keychain')
get_name = self.run_function('keychain.get_friendly_name', [CERT, PASSWD])
self.assertEqual(get_name, CERT_ALIAS)
|
'Test that attempts to get the default keychain'
| def test_mac_keychain_get_default_keychain(self):
| salt_get_keychain = self.run_function('keychain.get_default_keychain')
sys_get_keychain = self.run_function('cmd.run', ['security default-keychain -d user'])
self.assertEqual(salt_get_keychain, sys_get_keychain)
|
'Test that attempts to list certs'
| def test_mac_keychain_list_certs(self):
| cert_default = 'com.apple.systemdefault'
certs = self.run_function('keychain.list_certs')
self.assertIn(cert_default, certs)
|
'grains.items'
| def test_items(self):
| opts = self.minion_opts
self.assertEqual(self.run_function('grains.items')['test_grain'], opts['grains']['test_grain'])
|
'grains.item'
| def test_item(self):
| opts = self.minion_opts
self.assertEqual(self.run_function('grains.item', ['test_grain'])['test_grain'], opts['grains']['test_grain'])
|
'grains.ls'
| def test_ls(self):
| check_for = ('cpu_flags', 'cpu_model', 'cpuarch', 'domain', 'fqdn', 'gid', 'groupname', 'host', 'kernel', 'kernelrelease', 'kernelversion', 'localhost', 'mem_total', 'num_cpus', 'os', 'os_family', 'path', 'pid', 'ps', 'pythonpath', 'pythonversion', 'saltpath', 'saltversion', 'uid', 'username', 'virtual')
lsgrains = self.run_function('grains.ls')
os = self.run_function('grains.get', ['os'])
for grain in check_for:
if ((os == 'Windows') and (grain in ['cpu_flags', 'gid', 'groupname', 'uid'])):
continue
self.assertTrue((grain in lsgrains))
|
'test grains.set_val'
| @skipIf((os.environ.get('TRAVIS_PYTHON_VERSION', None) is not None), "Travis environment can't keep up with salt refresh")
def test_set_val(self):
| self.assertEqual(self.run_function('grains.setval', ['setgrain', 'grainval']), {'setgrain': 'grainval'})
time.sleep(5)
ret = self.run_function('grains.item', ['setgrain'])
if (not ret):
time.sleep(20)
ret = self.run_function('grains.item', ['setgrain'])
self.assertTrue(ret)
|
'test grains.get'
| def test_get(self):
| self.assertEqual(self.run_function('grains.get', ['level1:level2']), 'foo')
|
'test to ensure some core grains are returned'
| def test_get_core_grains(self):
| grains = ('os', 'os_family', 'osmajorrelease', 'osrelease', 'osfullname', 'id')
os = self.run_function('grains.get', ['os'])
for grain in grains:
get_grain = self.run_function('grains.get', [grain])
log.debug("Value of '%s' grain: '%s'", grain, get_grain)
if ((os == 'Arch') and (grain in ['osmajorrelease'])):
self.assertEqual(get_grain, '')
continue
if ((os == 'Windows') and (grain in ['osmajorrelease'])):
self.assertEqual(get_grain, '')
continue
self.assertTrue(get_grain)
|
'test to ensure int grains
are returned as integers'
| def test_get_grains_int(self):
| grains = ['num_cpus', 'mem_total', 'num_gpus', 'uid']
os = self.run_function('grains.get', ['os'])
for grain in grains:
get_grain = self.run_function('grains.get', [grain])
if ((os == 'Windows') and (grain in ['uid'])):
self.assertEqual(get_grain, '')
continue
self.assertIsInstance(get_grain, int, msg='grain: {0} is not an int or empty'.format(grain))
|
'Tests the return of a simple grains.append call.'
| def test_grains_append(self):
| ret = self.run_function('grains.append', [self.GRAIN_KEY, self.GRAIN_VAL])
self.assertEqual(ret[self.GRAIN_KEY], [self.GRAIN_VAL])
|
'Tests the return of a grains.append call when the value is already present in the grains list.'
| def test_grains_append_val_already_present(self):
| messaging = 'The val {0} was already in the list salttesting-grain-key'.format(self.GRAIN_VAL)
self.run_function('grains.append', [self.GRAIN_KEY, self.GRAIN_VAL])
ret = self.run_function('grains.append', [self.GRAIN_KEY, self.GRAIN_VAL])
self.assertEqual(messaging, ret)
|
'Tests the return of a grains.append call when val is passed in as a list.'
| def test_grains_append_val_is_list(self):
| second_grain = (self.GRAIN_VAL + '-2')
ret = self.run_function('grains.append', [self.GRAIN_KEY, [self.GRAIN_VAL, second_grain]])
self.assertEqual(ret[self.GRAIN_KEY], [self.GRAIN_VAL, second_grain])
|
'Tests the return of a grains.append call when the value is already present
but also ensure the grain is not listed twice.'
| def test_grains_append_call_twice(self):
| self.run_function('grains.append', [self.GRAIN_KEY, self.GRAIN_VAL])
self.run_function('grains.append', [self.GRAIN_KEY, self.GRAIN_VAL])
grains = self.run_function('grains.items')
count = 0
for grain in grains:
if (grain == self.GRAIN_KEY):
count += 1
self.assertEqual(count, 1)
|
'Sets up the test requirements'
| def setUp(self):
| super(DarwinSysctlModuleTest, self).setUp()
os_grain = self.run_function('grains.item', ['kernel'])
if (os_grain['kernel'] not in 'Darwin'):
self.skipTest("Test not applicable to '{kernel}' kernel".format(**os_grain))
self.has_conf = False
self.val = self.run_function('sysctl.get', [ASSIGN_CMD])
if os.path.isfile(CONFIG):
self.has_conf = True
try:
self.conf = self.__copy_sysctl()
except CommandExecutionError:
msg = 'Could not copy file: {0}'
raise CommandExecutionError(msg.format(CONFIG))
os.remove(CONFIG)
|
'Tests assigning a single sysctl parameter'
| def test_assign(self):
| try:
rand = random.randint(0, 500)
while (rand == self.val):
rand = random.randint(0, 500)
self.run_function('sysctl.assign', [ASSIGN_CMD, rand])
info = int(self.run_function('sysctl.get', [ASSIGN_CMD]))
try:
self.assertEqual(rand, info)
except AssertionError:
self.run_function('sysctl.assign', [ASSIGN_CMD, self.val])
raise
except CommandExecutionError:
self.run_function('sysctl.assign', [ASSIGN_CMD, self.val])
raise
|
'Tests assigning a sysctl value to a system without a sysctl.conf file'
| def test_persist_new_file(self):
| if os.path.isfile(CONFIG):
os.remove(CONFIG)
try:
self.run_function('sysctl.persist', [ASSIGN_CMD, 10])
line = '{0}={1}'.format(ASSIGN_CMD, 10)
found = self.__check_string(CONFIG, line)
try:
self.assertTrue(found)
except AssertionError:
raise
except CommandExecutionError:
os.remove(CONFIG)
raise
|
'Tests assigning a sysctl value that is already set in sysctl.conf file'
| def test_persist_already_set(self):
| if os.path.isfile(CONFIG):
os.remove(CONFIG)
try:
self.run_function('sysctl.persist', [ASSIGN_CMD, 50])
ret = self.run_function('sysctl.persist', [ASSIGN_CMD, 50])
try:
self.assertEqual(ret, 'Already set')
except AssertionError:
raise
except CommandExecutionError:
os.remove(CONFIG)
raise
|
'Tests assigning a sysctl value and applying the change to system'
| def test_persist_apply_change(self):
| if os.path.isfile(CONFIG):
os.remove(CONFIG)
try:
rand = random.randint(0, 500)
while (rand == self.val):
rand = random.randint(0, 500)
self.run_function('sysctl.persist', [ASSIGN_CMD, rand], apply_change=True)
info = int(self.run_function('sysctl.get', [ASSIGN_CMD]))
try:
self.assertEqual(info, rand)
except AssertionError:
raise
except CommandExecutionError:
os.remove(CONFIG)
raise
|
'Copies an existing sysconf file and returns temp file path. Copied
file will be restored in tearDown'
| def __copy_sysctl(self):
| temp_path = salt.utils.files.mkstemp()
with salt.utils.files.fopen(CONFIG, 'r') as org_conf:
with salt.utils.files.fopen(temp_path, 'w') as temp_sysconf:
for line in org_conf:
temp_sysconf.write(line)
return temp_path
|
'Restores the original sysctl.conf file from temporary copy'
| def __restore_sysctl(self):
| if os.path.isfile(CONFIG):
os.remove(CONFIG)
with salt.utils.files.fopen(self.conf, 'r') as temp_sysctl:
with salt.utils.files.fopen(CONFIG, 'w') as sysctl:
for line in temp_sysctl:
sysctl.write(line)
os.remove(self.conf)
|
'Returns True if given line is present in file'
| def __check_string(self, conf_file, to_find):
| with salt.utils.files.fopen(conf_file, 'r') as f_in:
for line in f_in:
if (to_find in line):
return True
return False
|
'Clean up after tests'
| def tearDown(self):
| ret = self.run_function('sysctl.get', [ASSIGN_CMD])
if (ret != self.val):
self.run_function('sysctl.assign', [ASSIGN_CMD, self.val])
if (self.has_conf is True):
self.__restore_sysctl()
if ((self.has_conf is False) and os.path.isfile(CONFIG)):
os.remove(CONFIG)
|
'Define the paths for the source, archive, and destination files
:param str arch_fmt: The archive format used in the test'
| def _set_artifact_paths(self, arch_fmt):
| self.src = os.path.join(self.base_path, '{0}_src_dir'.format(arch_fmt))
self.src_file = os.path.join(self.src, 'file')
self.arch = os.path.join(self.base_path, 'archive.{0}'.format(arch_fmt))
self.dst = os.path.join(self.base_path, '{0}_dst_dir'.format(arch_fmt))
|
'Create source file tree and destination directory
:param str arch_fmt: The archive format used in the test'
| def _set_up(self, arch_fmt):
| self._set_artifact_paths(arch_fmt)
if any([os.path.exists(f) for f in (self.src, self.arch, self.dst)]):
self._tear_down()
os.makedirs(self.src)
with salt.utils.files.fopen(os.path.join(self.src, 'file'), 'w') as theorem:
theorem.write(textwrap.dedent('\\\n Compression theorem of computational complexity theory:\n\n Given a G\xc3\xb6del numbering $\xcf\x86$ of the computable functions and a\n Blum complexity measure $\xce\xa6$ where a complexity class for a\n boundary function $f$ is defined as\n\n $\\mathrm C(f) := \\{\xcf\x86_i \xe2\x88\x88 \\mathbb R^{(1)} | (\xe2\x88\x80^\xe2\x88\x9e x) \xce\xa6_i(x) \xe2\x89\xa4 f(x)\\}$.\n\n Then there exists a total computable function $f$ so that for\n all $i$\n\n $\\mathrm{Dom}(\xcf\x86_i) = \\mathrm{Dom}(\xcf\x86_{f(i)})$\n\n and\n\n $\\mathrm C(\xcf\x86_i) \xe2\x8a\x8a \\mathrm{C}(\xcf\x86_{f(i)})$.\n '))
os.makedirs(self.dst)
|
'Remove source file tree, archive, and destination file tree'
| def _tear_down(self):
| for f in (self.src, self.arch, self.dst):
if os.path.exists(f):
if os.path.isdir(f):
shutil.rmtree(f, ignore_errors=True)
else:
os.remove(f)
del self.dst
del self.src
del self.arch
del self.src_file
|
'Assert that the artifact source files are printed in the source command
output'
| def _assert_artifacts_in_ret(self, ret, file_only=False):
| dir_in_ret = None
file_in_ret = None
for line in ret:
if ((self.src.lstrip('/') in line) and (not (self.src_file.lstrip('/') in line))):
dir_in_ret = True
if (self.src_file.lstrip('/') in line):
file_in_ret = True
self.assertTrue(((len(ret) >= 1) if file_only else 2))
if (not file_only):
self.assertTrue(dir_in_ret)
self.assertTrue(file_in_ret)
|
'Validate using the tar function to create archives'
| @skipIf((not salt.utils.path.which('tar')), 'Cannot find tar executable')
def test_tar_pack(self):
| self._set_up(arch_fmt='tar')
ret = self.run_function('archive.tar', ['-cvf', self.arch], sources=self.src)
self.assertTrue(isinstance(ret, list), str(ret))
self._assert_artifacts_in_ret(ret)
self._tear_down()
|
'Validate using the tar function to extract archives'
| @skipIf((not salt.utils.path.which('tar')), 'Cannot find tar executable')
def test_tar_unpack(self):
| self._set_up(arch_fmt='tar')
self.run_function('archive.tar', ['-cvf', self.arch], sources=self.src)
ret = self.run_function('archive.tar', ['-xvf', self.arch], dest=self.dst)
self.assertTrue(isinstance(ret, list), str(ret))
self._assert_artifacts_in_ret(ret)
self._tear_down()
|
'Validate using the gzip function'
| @skipIf((not salt.utils.path.which('gzip')), 'Cannot find gzip executable')
def test_gzip(self):
| self._set_up(arch_fmt='gz')
ret = self.run_function('archive.gzip', [self.src_file], options='-v')
self.assertTrue(isinstance(ret, list), str(ret))
self._assert_artifacts_in_ret(ret, file_only=True)
self._tear_down()
|
'Validate using the gunzip function'
| @skipIf((not salt.utils.path.which('gzip')), 'Cannot find gzip executable')
@skipIf((not salt.utils.path.which('gunzip')), 'Cannot find gunzip executable')
def test_gunzip(self):
| self._set_up(arch_fmt='gz')
self.run_function('archive.gzip', [self.src_file], options='-v')
ret = self.run_function('archive.gunzip', [(self.src_file + '.gz')], options='-v')
self.assertTrue(isinstance(ret, list), str(ret))
self._assert_artifacts_in_ret(ret, file_only=True)
self._tear_down()
|
'Validate using the cmd_zip function'
| @skipIf((not salt.utils.path.which('zip')), 'Cannot find zip executable')
def test_cmd_zip(self):
| self._set_up(arch_fmt='zip')
ret = self.run_function('archive.cmd_zip', [self.arch, self.src])
self.assertTrue(isinstance(ret, list), str(ret))
self._assert_artifacts_in_ret(ret)
self._tear_down()
|
'Validate using the cmd_unzip function'
| @skipIf((not salt.utils.path.which('zip')), 'Cannot find zip executable')
@skipIf((not salt.utils.path.which('unzip')), 'Cannot find unzip executable')
def test_cmd_unzip(self):
| self._set_up(arch_fmt='zip')
self.run_function('archive.cmd_zip', [self.arch, self.src])
ret = self.run_function('archive.cmd_unzip', [self.arch, self.dst])
self.assertTrue(isinstance(ret, list), str(ret))
self._assert_artifacts_in_ret(ret)
self._tear_down()
|
'Validate using the zip function'
| @skipIf((not HAS_ZIPFILE), 'Cannot find zipfile python module')
def test_zip(self):
| self._set_up(arch_fmt='zip')
ret = self.run_function('archive.zip', [self.arch, self.src])
self.assertTrue(isinstance(ret, list), str(ret))
self._assert_artifacts_in_ret(ret)
self._tear_down()
|
'Validate using the unzip function'
| @skipIf((not HAS_ZIPFILE), 'Cannot find zipfile python module')
def test_unzip(self):
| self._set_up(arch_fmt='zip')
self.run_function('archive.zip', [self.arch, self.src])
ret = self.run_function('archive.unzip', [self.arch, self.dst])
self.assertTrue(isinstance(ret, list), str(ret))
self._assert_artifacts_in_ret(ret)
self._tear_down()
|
'Validate using the rar function'
| @skipIf((not salt.utils.path.which('rar')), 'Cannot find rar executable')
def test_rar(self):
| self._set_up(arch_fmt='rar')
ret = self.run_function('archive.rar', [self.arch, self.src])
self.assertTrue(isinstance(ret, list), str(ret))
self._assert_artifacts_in_ret(ret)
self._tear_down()
|
'Validate using the unrar function'
| @skipIf((not salt.utils.path.which('rar')), 'Cannot find rar executable')
@skipIf((not salt.utils.path.which('unrar')), 'Cannot find unrar executable')
def test_unrar(self):
| self._set_up(arch_fmt='rar')
self.run_function('archive.rar', [self.arch, self.src])
ret = self.run_function('archive.unrar', [self.arch, self.dst])
self.assertTrue(isinstance(ret, list), str(ret))
self._assert_artifacts_in_ret(ret)
self._tear_down()
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.