test_napalm_users.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # -*- coding: utf-8 -*-
  2. """
  3. :codeauthor: :email:`Anthony Shaw <anthonyshaw@apache.org>`
  4. """
  5. # Import Python Libs
  6. from __future__ import absolute_import, print_function, unicode_literals
  7. import tests.support.napalm as napalm_test_support
  8. # Import Salt Testing Libs
  9. from tests.support.mixins import LoaderModuleMockMixin
  10. from tests.support.mock import MagicMock
  11. from tests.support.unit import TestCase
  12. import salt.modules.napalm_users as napalm_users # NOQA
  13. import salt.modules.napalm_network as napalm_network # NOQA
  14. class NapalmUsersModuleTestCase(TestCase, LoaderModuleMockMixin):
  15. def setup_loader_modules(self):
  16. module_globals = {
  17. "__salt__": {
  18. "config.option": MagicMock(
  19. return_value={"test": {"driver": "test", "key": "2orgk34kgk34g"}}
  20. ),
  21. "file.file_exists": napalm_test_support.true,
  22. "file.join": napalm_test_support.join,
  23. "file.get_managed": napalm_test_support.get_managed_file,
  24. "random.hash": napalm_test_support.random_hash,
  25. "net.load_template": napalm_network.load_template,
  26. }
  27. }
  28. return {napalm_users: module_globals, napalm_network: module_globals}
  29. def test_config(self):
  30. ret = napalm_users.config()
  31. assert ret["out"] == napalm_test_support.TEST_USERS
  32. def test_set_users(self):
  33. ret = napalm_users.set_users({"mircea": {}})
  34. assert ret["result"] is False
  35. def test_delete_users(self):
  36. ret = napalm_users.delete_users({"mircea": {}})
  37. assert ret["result"] is False