test_hgfs.py (salt-3002.1) | : | test_hgfs.py (salt-3002.2) | ||
---|---|---|---|---|
# -*- coding: utf-8 -*- | ||||
# Import Python libs | ||||
from __future__ import absolute_import, print_function, unicode_literals | ||||
# Import Salt libs | ||||
import salt.fileserver.hgfs as hgfs | import salt.fileserver.hgfs as hgfs | |||
# Import Salt Testing libs | ||||
from tests.support.mixins import LoaderModuleMockMixin | from tests.support.mixins import LoaderModuleMockMixin | |||
from tests.support.mock import patch | from tests.support.mock import patch | |||
from tests.support.unit import TestCase | from tests.support.unit import TestCase, skipIf | |||
class HgfsFileTest(TestCase, LoaderModuleMockMixin): | class HgfsFileTest(TestCase, LoaderModuleMockMixin): | |||
def setup_loader_modules(self): | def setup_loader_modules(self): | |||
return {hgfs: {}} | return {hgfs: {}} | |||
def test_env_is_exposed(self): | def test_env_is_exposed(self): | |||
""" | """ | |||
test _env_is_exposed method when | test _env_is_exposed method when | |||
base is in whitelist | base is in whitelist | |||
""" | """ | |||
skipping to change at line 39 | skipping to change at line 31 | |||
def test_env_is_exposed_blacklist(self): | def test_env_is_exposed_blacklist(self): | |||
""" | """ | |||
test _env_is_exposed method when | test _env_is_exposed method when | |||
base is in blacklist | base is in blacklist | |||
""" | """ | |||
with patch.dict( | with patch.dict( | |||
hgfs.__opts__, | hgfs.__opts__, | |||
{"hgfs_saltenv_whitelist": "", "hgfs_saltenv_blacklist": "base"}, | {"hgfs_saltenv_whitelist": "", "hgfs_saltenv_blacklist": "base"}, | |||
): | ): | |||
assert not hgfs._env_is_exposed("base") | assert not hgfs._env_is_exposed("base") | |||
@skipIf(not hgfs.HAS_HG, "hglib needs to be installed") | ||||
def test_fix_58852(self): | ||||
""" | ||||
test to make sure python 3 can init hgfs | ||||
""" | ||||
with patch.dict( | ||||
hgfs.__opts__, | ||||
{ | ||||
"cachedir": "/tmp/barf", | ||||
"hgfs_base": "fnord", | ||||
"hgfs_branch_method": "fnord", | ||||
"hgfs_mountpoint": "fnord", | ||||
"hgfs_root": "fnord", | ||||
"hgfs_remotes": "fnord", | ||||
}, | ||||
): | ||||
self.assertIsInstance(hgfs.init(), list) | ||||
End of changes. 4 change blocks. | ||||
9 lines changed or deleted | 1 lines changed or added |