1
0

test_man.py 3.4 KB

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