mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
75 lines
2.1 KiB
Python
75 lines
2.1 KiB
Python
# -*- coding: utf-8 -*-
|
|
'''
|
|
:codeauthor: :email:`Eric Radman <ericshane@eradman.com`
|
|
'''
|
|
|
|
# Import python libs
|
|
from __future__ import absolute_import
|
|
import tempfile
|
|
import os.path
|
|
|
|
# Import Salt Testing libs
|
|
from salttesting import TestCase, skipIf
|
|
from salttesting.helpers import ensure_in_syspath
|
|
from salttesting.mock import MagicMock, patch, NO_MOCK, NO_MOCK_REASON
|
|
|
|
ensure_in_syspath('../')
|
|
|
|
# Import Salt libs
|
|
import integration
|
|
from salt.states import saltmod
|
|
|
|
|
|
@skipIf(NO_MOCK, NO_MOCK_REASON)
|
|
class StatemodTests(TestCase):
|
|
def setUp(self):
|
|
self.tmp_cachedir = tempfile.mkdtemp(dir=integration.TMP)
|
|
|
|
@patch('salt.states.saltmod.__salt__', MagicMock())
|
|
def test_statemod_state(self):
|
|
''' Smoke test for for salt.states.statemod.state(). Ensures that we
|
|
don't take an exception if optional parameters are not specified in
|
|
__opts__ or __env__.
|
|
'''
|
|
argv = []
|
|
saltmod.__opts__ = {
|
|
'id': 'webserver2',
|
|
'argv': argv,
|
|
'__role': 'master',
|
|
'cachedir': self.tmp_cachedir,
|
|
'extension_modules': os.path.join(self.tmp_cachedir, 'extmods'),
|
|
}
|
|
args = ('webserver_setup', 'webserver2')
|
|
kwargs = {
|
|
'tgt_type': 'glob',
|
|
'fail_minions': None,
|
|
'pillar': None,
|
|
'top': None,
|
|
'batch': None,
|
|
'orchestration_jid': None,
|
|
'sls': 'vroom',
|
|
'queue': False,
|
|
'concurrent': False,
|
|
'highstate': None,
|
|
'expr_form': None,
|
|
'ret': '',
|
|
'ssh': False,
|
|
'timeout': None, 'test': False,
|
|
'allow_fail': 0,
|
|
'saltenv': None,
|
|
'expect_minions': False
|
|
}
|
|
ret = saltmod.state(*args, **kwargs)
|
|
expected = {
|
|
'comment': 'States ran successfully.',
|
|
'changes': {},
|
|
'name': 'webserver_setup',
|
|
'result': True
|
|
}
|
|
self.assertEqual(ret, expected)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
from integration import run_tests
|
|
run_tests(StatemodTests, needs_daemon=False)
|