test_man.py 3.8 KB

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