test_man.py 3.4 KB

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