salt/tests/unit/modules/test_win_file.py

49 lines
1.5 KiB
Python
Raw Normal View History

2017-09-07 19:33:21 +00:00
# -*- coding: utf-8 -*-
'''
:codeauthor: Shane Lee <slee@saltstack.com>
2017-09-07 19:33:21 +00:00
'''
# Import Python Libs
from __future__ import absolute_import, unicode_literals, print_function
2017-09-07 19:33:21 +00:00
import os
# Import Salt Testing Libs
from tests.support.unit import TestCase, skipIf
from tests.support.mock import patch, NO_MOCK, NO_MOCK_REASON
2017-09-07 19:33:21 +00:00
# Import Salt Libs
import salt.modules.win_file as win_file
from salt.exceptions import CommandExecutionError
import salt.utils.platform
import salt.utils.win_dacl
2017-09-07 19:33:21 +00:00
@skipIf(NO_MOCK, NO_MOCK_REASON)
class WinFileTestCase(TestCase):
2017-09-07 19:33:21 +00:00
'''
Test cases for salt.modules.win_file
'''
FAKE_RET = {'fake': 'ret data'}
if salt.utils.platform.is_windows():
FAKE_PATH = os.sep.join(['C:', 'path', 'does', 'not', 'exist'])
else:
FAKE_PATH = os.sep.join(['path', 'does', 'not', 'exist'])
2017-09-07 19:33:21 +00:00
def test_issue_43328_stats(self):
'''
2017-09-13 23:10:15 +00:00
Make sure that a CommandExecutionError is raised if the file does NOT
exist
2017-09-07 19:33:21 +00:00
'''
with patch('os.path.exists', return_value=False):
2017-09-11 17:30:18 +00:00
self.assertRaises(CommandExecutionError,
win_file.stats,
self.FAKE_PATH)
2017-09-07 19:33:21 +00:00
def test_issue_43328_check_perms_no_ret(self):
'''
2017-09-13 23:10:15 +00:00
Make sure that a CommandExecutionError is raised if the file does NOT
exist
2017-09-07 19:33:21 +00:00
'''
with patch('os.path.exists', return_value=False):
self.assertRaises(
CommandExecutionError, win_file.check_perms, self.FAKE_PATH)