1
0

test_engines.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. # -*- coding: utf-8 -*-
  2. '''
  3. unit tests for the Salt engines
  4. '''
  5. # Import Python libs
  6. from __future__ import absolute_import, print_function, unicode_literals
  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. patch)
  12. # Import Salt Libs
  13. import salt.engines as engines
  14. import salt.config
  15. import salt.utils.process
  16. # Import 3rd-party libs
  17. from salt.ext import six
  18. import logging
  19. log = logging.getLogger(__name__)
  20. class EngineTestCase(TestCase, LoaderModuleMockMixin):
  21. '''
  22. Test cases for salt.engine.sqs_events
  23. '''
  24. def setup_loader_modules(self):
  25. return {engines: {}}
  26. def test_engine_module(self):
  27. '''
  28. Test
  29. '''
  30. mock_opts = salt.config.DEFAULT_MINION_OPTS.copy()
  31. mock_opts['__role'] = 'minion'
  32. mock_opts['engines'] = [{'test_one': {'engine_module': 'test'}},
  33. {'test_two': {'engine_module': 'test'}}]
  34. process_manager = salt.utils.process.ProcessManager()
  35. with patch.dict(engines.__opts__, mock_opts):
  36. salt.engines.start_engines(mock_opts, process_manager)
  37. process_map = process_manager._process_map
  38. count = 0
  39. for proc in six.iterkeys(process_map):
  40. count += 1
  41. fun = process_map[proc]['Process'].fun
  42. # Ensure function is start from the test engine
  43. self.assertEqual(fun, 'test.start')
  44. # Ensure there were two engine started
  45. self.assertEqual(count, len(mock_opts['engines']))