salt/tests/unit/modules/win_shadow_test.py

62 lines
1.8 KiB
Python
Raw Normal View History

2015-02-25 13:18:05 +00:00
# -*- coding: utf-8 -*-
'''
:codeauthor: :email:`Jayesh Kariya <jayeshk@saltstack.com>`
'''
# Import Python Libs
from __future__ import absolute_import
# Import Salt Testing Libs
from salttesting import TestCase, skipIf
from salttesting.mock import (
MagicMock,
patch
)
from salttesting.helpers import ensure_in_syspath
ensure_in_syspath('../../')
# Import Salt Libs
from salt.modules import win_shadow
2015-12-21 18:25:18 +00:00
import salt.utils
2015-02-25 13:18:05 +00:00
# Globals
win_shadow.__salt__ = {}
2015-12-21 18:25:18 +00:00
@skipIf(not salt.utils.is_windows(), 'This test case runs only on Windows systems')
2015-02-25 13:18:05 +00:00
class WinShadowTestCase(TestCase):
'''
Test cases for salt.modules.win_shadow
'''
# 'info' function tests: 1
def test_info(self):
'''
Test if it return information for the specified user
'''
self.assertDictEqual(win_shadow.info('SALT'), {'name': 'SALT',
'passwd': '',
'lstchg': '',
'min': '',
'max': '',
'warn': '',
'inact': '',
'expire': ''})
# 'set_password' function tests: 1
def test_set_password(self):
'''
Test if it set the password for a named user.
'''
mock_cmd = MagicMock(return_value={'retcode': False})
with patch.dict(win_shadow.__salt__, {'cmd.run_all': mock_cmd}):
self.assertTrue(win_shadow.set_password('root', 'mysecretpassword'))
if __name__ == '__main__':
from integration import run_tests
run_tests(WinShadowTestCase, needs_daemon=False)