1
0

test_napalm_route.py 1.4 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, 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_route as napalm_route # NOQA
  15. def mock_net_load(template, *args, **kwargs):
  16. raise ValueError("incorrect template {0}".format(template))
  17. class NapalmRouteModuleTestCase(TestCase, LoaderModuleMockMixin):
  18. def setup_loader_modules(self):
  19. module_globals = {
  20. '__salt__': {
  21. 'config.option': MagicMock(return_value={
  22. 'test': {
  23. 'driver': 'test',
  24. 'key': '2orgk34kgk34g'
  25. }
  26. }),
  27. 'file.file_exists': napalm_test_support.true,
  28. 'file.join': napalm_test_support.join,
  29. 'file.get_managed': napalm_test_support.get_managed_file,
  30. 'random.hash': napalm_test_support.random_hash,
  31. 'net.load_template': mock_net_load
  32. }
  33. }
  34. return {napalm_route: module_globals}
  35. def test_show(self):
  36. ret = napalm_route.show('1.2.3.4')
  37. assert ret['out'] == napalm_test_support.TEST_ROUTE