2013-12-09 23:47:49 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
'''
|
2014-05-22 00:59:02 +00:00
|
|
|
:codeauthor: :email:`Mike Place <mp@saltstack.com>`
|
2013-12-09 23:47:49 +00:00
|
|
|
'''
|
2014-11-21 19:05:13 +00:00
|
|
|
# Import Python libs
|
|
|
|
from __future__ import absolute_import
|
2013-12-09 23:47:49 +00:00
|
|
|
|
|
|
|
# Import Salt Testing libs
|
2014-02-08 07:51:28 +00:00
|
|
|
from salttesting.unit import skipIf
|
|
|
|
from salttesting.helpers import ensure_in_syspath
|
|
|
|
from salttesting.mock import MagicMock, patch, NO_MOCK, NO_MOCK_REASON
|
2014-06-05 14:56:20 +00:00
|
|
|
ensure_in_syspath('../..')
|
2013-12-09 23:47:49 +00:00
|
|
|
|
|
|
|
# Import salt libs
|
|
|
|
import integration
|
|
|
|
from salt import fileclient
|
|
|
|
|
|
|
|
|
2014-02-08 07:51:28 +00:00
|
|
|
@skipIf(NO_MOCK, NO_MOCK_REASON)
|
2013-12-09 23:47:49 +00:00
|
|
|
class FileClientTest(integration.ModuleCase):
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
self.file_client = fileclient.Client(self.master_opts)
|
|
|
|
|
|
|
|
def test_file_list_emptydirs(self):
|
|
|
|
'''
|
|
|
|
Ensure that the fileclient class won't allow a direct call to file_list_emptydirs()
|
|
|
|
'''
|
|
|
|
with self.assertRaises(NotImplementedError):
|
|
|
|
self.file_client.file_list_emptydirs()
|
|
|
|
|
|
|
|
def test_get_file(self):
|
|
|
|
'''
|
|
|
|
Ensure that the fileclient class won't allow a direct call to get_file()
|
|
|
|
'''
|
|
|
|
with self.assertRaises(NotImplementedError):
|
|
|
|
self.file_client.get_file(None)
|
|
|
|
|
|
|
|
def test_get_file_client(self):
|
2014-10-07 11:19:58 +00:00
|
|
|
with patch.dict(self.get_config('minion', from_scratch=True), {'file_client': 'remote'}):
|
2013-12-09 23:47:49 +00:00
|
|
|
with patch('salt.fileclient.RemoteClient', MagicMock(return_value='remote_client')):
|
|
|
|
ret = fileclient.get_file_client(self.minion_opts)
|
|
|
|
self.assertEqual('remote_client', ret)
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
from integration import run_tests
|
|
|
|
run_tests(FileClientTest)
|