test_test.py 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. # -*- coding: utf-8 -*-
  2. # Import Python libs
  3. from __future__ import absolute_import, print_function, unicode_literals
  4. # Import Salt Testing libs
  5. from tests.support.case import ModuleCase
  6. from tests.support.mixins import AdaptedConfigurationTestCaseMixin
  7. # Import salt libs
  8. import salt.version
  9. import salt.config
  10. import pytest
  11. @pytest.mark.windows_whitelisted
  12. class TestModuleTest(ModuleCase, AdaptedConfigurationTestCaseMixin):
  13. '''
  14. Validate the test module
  15. '''
  16. def test_ping(self):
  17. '''
  18. test.ping
  19. '''
  20. self.assertTrue(self.run_function('test.ping'))
  21. def test_echo(self):
  22. '''
  23. test.echo
  24. '''
  25. self.assertEqual(self.run_function('test.echo', ['text']), 'text')
  26. def test_version(self):
  27. '''
  28. test.version
  29. '''
  30. self.assertEqual(self.run_function('test.version'),
  31. salt.version.__saltstack_version__.string)
  32. def test_conf_test(self):
  33. '''
  34. test.conf_test
  35. '''
  36. self.assertEqual(self.run_function('test.conf_test'), 'baz')
  37. def test_get_opts(self):
  38. '''
  39. test.get_opts
  40. '''
  41. opts = salt.config.minion_config(
  42. self.get_config_file_path('minion')
  43. )
  44. self.assertEqual(
  45. self.run_function('test.get_opts')['cachedir'],
  46. opts['cachedir']
  47. )
  48. def test_cross_test(self):
  49. '''
  50. test.cross_test
  51. '''
  52. self.assertTrue(
  53. self.run_function(
  54. 'test.cross_test',
  55. ['test.ping']
  56. )
  57. )
  58. def test_fib(self):
  59. '''
  60. test.fib
  61. '''
  62. self.assertEqual(
  63. self.run_function(
  64. 'test.fib',
  65. ['20'],
  66. )[0],
  67. 6765
  68. )
  69. def test_collatz(self):
  70. '''
  71. test.collatz
  72. '''
  73. self.assertEqual(
  74. self.run_function(
  75. 'test.collatz',
  76. ['40'],
  77. )[0][-1],
  78. 2
  79. )
  80. def test_outputter(self):
  81. '''
  82. test.outputter
  83. '''
  84. self.assertEqual(self.run_function('test.outputter', ['text']), 'text')