"Fossies" - the Fresh Open Source Software Archive

Member "salt-3002.2/tests/unit/fileserver/test_hgfs.py" (18 Nov 2020, 1503 Bytes) of package /linux/misc/salt-3002.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "test_hgfs.py": 3002.1_vs_3002.2.

    1 import salt.fileserver.hgfs as hgfs
    2 from tests.support.mixins import LoaderModuleMockMixin
    3 from tests.support.mock import patch
    4 from tests.support.unit import TestCase, skipIf
    5 
    6 
    7 class HgfsFileTest(TestCase, LoaderModuleMockMixin):
    8     def setup_loader_modules(self):
    9         return {hgfs: {}}
   10 
   11     def test_env_is_exposed(self):
   12         """
   13         test _env_is_exposed method when
   14         base is in whitelist
   15         """
   16         with patch.dict(
   17             hgfs.__opts__,
   18             {"hgfs_saltenv_whitelist": "base", "hgfs_saltenv_blacklist": ""},
   19         ):
   20             assert hgfs._env_is_exposed("base")
   21 
   22     def test_env_is_exposed_blacklist(self):
   23         """
   24         test _env_is_exposed method when
   25         base is in blacklist
   26         """
   27         with patch.dict(
   28             hgfs.__opts__,
   29             {"hgfs_saltenv_whitelist": "", "hgfs_saltenv_blacklist": "base"},
   30         ):
   31             assert not hgfs._env_is_exposed("base")
   32 
   33     @skipIf(not hgfs.HAS_HG, "hglib needs to be installed")
   34     def test_fix_58852(self):
   35         """
   36         test to make sure python 3 can init hgfs
   37         """
   38         with patch.dict(
   39             hgfs.__opts__,
   40             {
   41                 "cachedir": "/tmp/barf",
   42                 "hgfs_base": "fnord",
   43                 "hgfs_branch_method": "fnord",
   44                 "hgfs_mountpoint": "fnord",
   45                 "hgfs_root": "fnord",
   46                 "hgfs_remotes": "fnord",
   47             },
   48         ):
   49             self.assertIsInstance(hgfs.init(), list)