test_fileserver.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. # -*- coding: utf-8 -*-
  2. """
  3. :codeauthor: Joao Mesquita <jmesquita@sangoma.com>
  4. """
  5. # Import Python libs
  6. from __future__ import absolute_import, print_function, unicode_literals
  7. from salt import fileserver
  8. # Import Salt Testing libs
  9. from tests.support.mixins import LoaderModuleMockMixin
  10. from tests.support.unit import TestCase
  11. class MapDiffTestCase(TestCase):
  12. def test_diff_with_diffent_keys(self):
  13. """
  14. Test that different maps are indeed reported different
  15. """
  16. map1 = {"file1": 1234}
  17. map2 = {"file2": 1234}
  18. assert fileserver.diff_mtime_map(map1, map2) is True
  19. def test_diff_with_diffent_values(self):
  20. """
  21. Test that different maps are indeed reported different
  22. """
  23. map1 = {"file1": 12345}
  24. map2 = {"file1": 1234}
  25. assert fileserver.diff_mtime_map(map1, map2) is True
  26. class VCSBackendWhitelistCase(TestCase, LoaderModuleMockMixin):
  27. def setup_loader_modules(self):
  28. return {fileserver: {}}
  29. def test_whitelist(self):
  30. opts = {
  31. "fileserver_backend": ["roots", "git", "hgfs", "svn"],
  32. "extension_modules": "",
  33. }
  34. fs = fileserver.Fileserver(opts)
  35. assert fs.servers.whitelist == [
  36. "git",
  37. "gitfs",
  38. "hg",
  39. "hgfs",
  40. "svn",
  41. "svnfs",
  42. "roots",
  43. ], fs.servers.whitelist