1
0

test_eselect.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # -*- coding: utf-8 -*-
  2. """
  3. :codeauthor: Jayesh Kariya <jayeshk@saltstack.com>
  4. """
  5. # Import Python libs
  6. from __future__ import absolute_import, print_function, unicode_literals
  7. # Import Salt Libs
  8. import salt.states.eselect as eselect
  9. # Import Salt Testing Libs
  10. from tests.support.mixins import LoaderModuleMockMixin
  11. from tests.support.mock import MagicMock, patch
  12. from tests.support.unit import TestCase
  13. class EselectTestCase(TestCase, LoaderModuleMockMixin):
  14. """
  15. Test cases for salt.states.eselect
  16. """
  17. def setup_loader_modules(self):
  18. return {eselect: {}}
  19. # 'set_' function tests: 1
  20. def test_set_(self):
  21. """
  22. Test to verify that the given module is set to the given target
  23. """
  24. name = "myeselect"
  25. target = "hardened/linux/amd64"
  26. ret = {"name": name, "result": True, "comment": "", "changes": {}}
  27. mock = MagicMock(return_value=target)
  28. with patch.dict(eselect.__salt__, {"eselect.get_current_target": mock}):
  29. comt = "Target '{0}' is already set on '{1}' module.".format(target, name)
  30. ret.update({"comment": comt})
  31. self.assertDictEqual(eselect.set_(name, target), ret)