1
0

test_hgfs.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. class HgfsFileTest(TestCase, LoaderModuleMockMixin):
  6. def setup_loader_modules(self):
  7. return {hgfs: {}}
  8. def test_env_is_exposed(self):
  9. """
  10. test _env_is_exposed method when
  11. base is in whitelist
  12. """
  13. with patch.dict(
  14. hgfs.__opts__,
  15. {"hgfs_saltenv_whitelist": "base", "hgfs_saltenv_blacklist": ""},
  16. ):
  17. assert hgfs._env_is_exposed("base")
  18. def test_env_is_exposed_blacklist(self):
  19. """
  20. test _env_is_exposed method when
  21. base is in blacklist
  22. """
  23. with patch.dict(
  24. hgfs.__opts__,
  25. {"hgfs_saltenv_whitelist": "", "hgfs_saltenv_blacklist": "base"},
  26. ):
  27. assert not hgfs._env_is_exposed("base")
  28. @skipIf(not hgfs.HAS_HG, "hglib needs to be installed")
  29. def test_fix_58852(self):
  30. """
  31. test to make sure python 3 can init hgfs
  32. """
  33. with patch.dict(
  34. hgfs.__opts__,
  35. {
  36. "cachedir": "/tmp/barf",
  37. "hgfs_base": "fnord",
  38. "hgfs_branch_method": "fnord",
  39. "hgfs_mountpoint": "fnord",
  40. "hgfs_root": "fnord",
  41. "hgfs_remotes": "fnord",
  42. },
  43. ):
  44. self.assertIsInstance(hgfs.init(), list)