test_napalm_snmp.py 1.7 KB

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