test_pkgng.py 1020 B

12345678910111213141516171819202122232425262728293031323334353637
  1. # -*- coding: utf-8 -*-
  2. """
  3. :codeauthor: Jayesh Kariya <jayeshk@saltstack.com>
  4. """
  5. # Import Python libs
  6. from __future__ import absolute_import
  7. # Import Salt Libs
  8. import salt.states.pkgng as pkgng
  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 PkgngTestCase(TestCase, LoaderModuleMockMixin):
  14. """
  15. Test cases for salt.states.pkgng
  16. """
  17. def setup_loader_modules(self):
  18. return {pkgng: {}}
  19. # 'update_packaging_site' function tests: 1
  20. def test_update_packaging_site(self):
  21. """
  22. Test to execute update_packaging_site.
  23. """
  24. name = "http://192.168.0.2"
  25. ret = {"name": name, "result": True, "comment": "", "changes": {}}
  26. mock_t = MagicMock(return_value=True)
  27. with patch.dict(pkgng.__salt__, {"pkgng.update_package_site": mock_t}):
  28. self.assertDictEqual(pkgng.update_packaging_site(name), ret)