test_test.py 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. class TestModuleTest(ModuleCase, AdaptedConfigurationTestCaseMixin):
  11. '''
  12. Validate the test module
  13. '''
  14. def test_ping(self):
  15. '''
  16. test.ping
  17. '''
  18. self.assertTrue(self.run_function('test.ping'))
  19. def test_echo(self):
  20. '''
  21. test.echo
  22. '''
  23. self.assertEqual(self.run_function('test.echo', ['text']), 'text')
  24. def test_version(self):
  25. '''
  26. test.version
  27. '''
  28. self.assertEqual(self.run_function('test.version'),
  29. salt.version.__saltstack_version__.string)
  30. def test_conf_test(self):
  31. '''
  32. test.conf_test
  33. '''
  34. self.assertEqual(self.run_function('test.conf_test'), 'baz')
  35. def test_get_opts(self):
  36. '''
  37. test.get_opts
  38. '''
  39. opts = salt.config.minion_config(
  40. self.get_config_file_path('minion')
  41. )
  42. self.assertEqual(
  43. self.run_function('test.get_opts')['cachedir'],
  44. opts['cachedir']
  45. )
  46. def test_cross_test(self):
  47. '''
  48. test.cross_test
  49. '''
  50. self.assertTrue(
  51. self.run_function(
  52. 'test.cross_test',
  53. ['test.ping']
  54. )
  55. )
  56. def test_fib(self):
  57. '''
  58. test.fib
  59. '''
  60. self.assertEqual(
  61. self.run_function(
  62. 'test.fib',
  63. ['20'],
  64. )[0],
  65. 6765
  66. )
  67. def test_collatz(self):
  68. '''
  69. test.collatz
  70. '''
  71. self.assertEqual(
  72. self.run_function(
  73. 'test.collatz',
  74. ['40'],
  75. )[0][-1],
  76. 2
  77. )
  78. def test_outputter(self):
  79. '''
  80. test.outputter
  81. '''
  82. self.assertEqual(self.run_function('test.outputter', ['text']), 'text')