test_napalm_snmp.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_snmp as napalm_snmp # NOQA
  13. import salt.modules.napalm_network as napalm_network # NOQA
  14. class NapalmSnmpModuleTestCase(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_snmp: module_globals, napalm_network: module_globals}
  29. def test_config(self):
  30. ret = napalm_snmp.config()
  31. assert ret["out"] == napalm_test_support.TEST_SNMP_INFO
  32. def test_remove_config(self):
  33. ret = napalm_snmp.remove_config("1.2.3.4")
  34. assert ret["result"] is False
  35. def test_update_config(self):
  36. ret = napalm_snmp.update_config("1.2.3.4")
  37. assert ret["result"] is False