test_man.py 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. # -*- coding: utf-8 -*-
  2. '''
  3. Tests for existence of manpages
  4. '''
  5. # Import python libs
  6. from __future__ import absolute_import, print_function, unicode_literals
  7. import os
  8. import pprint
  9. import shutil
  10. # Import Salt libs
  11. import salt.utils.platform
  12. # Import Salt Testing libs
  13. from tests.support.runtests import RUNTIME_VARS
  14. from tests.support.case import ModuleCase
  15. from tests.support.unit import skipIf
  16. @skipIf(salt.utils.platform.is_windows(), 'minion is windows')
  17. class ManTest(ModuleCase):
  18. @classmethod
  19. def setUpClass(cls):
  20. cls.rootdir = os.path.join(RUNTIME_VARS.TMP, 'mantest')
  21. # Map filenames to search strings which should be in the manpage
  22. cls.manpages = {
  23. 'salt-cp.1': [
  24. 'salt-cp Documentation',
  25. 'copies files from the master',
  26. ],
  27. 'salt-cloud.1': [
  28. 'Salt Cloud Command',
  29. 'Provision virtual machines in the cloud',
  30. ],
  31. 'salt-call.1': [
  32. 'salt-call Documentation',
  33. 'run module functions locally',
  34. ],
  35. 'salt-api.1': [
  36. 'salt-api Command',
  37. 'Start interfaces used to remotely connect',
  38. ],
  39. 'salt-unity.1': [
  40. 'salt-unity Command',
  41. 'unified invocation wrapper',
  42. ],
  43. 'salt-syndic.1': [
  44. 'salt-syndic Documentation',
  45. 'Salt syndic daemon',
  46. ],
  47. 'salt-ssh.1': [
  48. 'salt-ssh Documentation',
  49. 'executed using only SSH',
  50. ],
  51. 'salt-run.1': [
  52. 'salt-run Documentation',
  53. 'frontend command for executing',
  54. ],
  55. 'salt-proxy.1': [
  56. 'salt-proxy Documentation',
  57. 'proxies these commands',
  58. ],
  59. 'salt-minion.1': [
  60. 'salt-minion Documentation',
  61. 'Salt minion daemon',
  62. ],
  63. 'salt-master.1': [
  64. 'salt-master Documentation',
  65. 'Salt master daemon',
  66. ],
  67. 'salt-key.1': [
  68. 'salt-key Documentation',
  69. 'management of Salt server public keys',
  70. ],
  71. 'salt.1': [
  72. 'allows for commands to be executed',
  73. ],
  74. 'salt.7': [
  75. 'Salt Documentation',
  76. ],
  77. 'spm.1': [
  78. 'Salt Package Manager Command',
  79. 'command for managing Salt packages',
  80. ],
  81. }
  82. @classmethod
  83. def tearDownClass(cls):
  84. cls.manpages = None
  85. def setUp(self):
  86. self.addCleanup(shutil.rmtree, self.rootdir, ignore_errors=True)
  87. if not os.path.exists(self.rootdir):
  88. ret = self.run_function('mantest.install', [self.rootdir])
  89. if not isinstance(ret, dict):
  90. self.fail(
  91. 'The \'mantest.install\' command did not return the excepted dictionary. Output:\n{}'.format(
  92. ret
  93. )
  94. )
  95. if ret['retcode'] != 0:
  96. self.fail(
  97. 'Failed to install. Full return dictionary:\n{}'.format(
  98. pprint.pformat(ret)
  99. )
  100. )
  101. def test_man(self):
  102. '''
  103. Make sure that man pages are installed
  104. '''
  105. ret = self.run_function('mantest.search', [self.manpages, self.rootdir])
  106. # The above function returns True if successful and an exception (which
  107. # will manifest in the return as a stringified exception) if
  108. # unsuccessful. Therefore, a simple assertTrue is not sufficient.
  109. if ret is not True:
  110. self.fail(ret)