1
0

test_cache.py 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. # -*- coding: utf-8 -*-
  2. '''
  3. Tests for the salt-run command
  4. '''
  5. # Import Python libs
  6. from __future__ import absolute_import, print_function, unicode_literals
  7. # Import Salt Testing libs
  8. from tests.support.case import ShellCase
  9. import logging
  10. log = logging.getLogger(__name__)
  11. class ManageTest(ShellCase):
  12. '''
  13. Test the manage runner
  14. '''
  15. def test_cache(self):
  16. '''
  17. Store, list, fetch, then flush data
  18. '''
  19. # Store the data
  20. ret = self.run_run_plus(
  21. 'cache.store',
  22. bank='cachetest/runner',
  23. key='test_cache',
  24. data='The time has come the walrus said',
  25. )
  26. # Make sure we can see the new key
  27. ret = self.run_run_plus('cache.list', bank='cachetest/runner')
  28. self.assertIn('test_cache', ret['return'])
  29. # Make sure we can see the new data
  30. ret = self.run_run_plus('cache.fetch', bank='cachetest/runner', key='test_cache')
  31. self.assertIn('The time has come the walrus said', ret['return'])
  32. # Make sure we can delete the data
  33. ret = self.run_run_plus('cache.flush', bank='cachetest/runner', key='test_cache')
  34. ret = self.run_run_plus('cache.list', bank='cachetest/runner')
  35. self.assertNotIn('test_cache', ret['return'])
  36. def test_cache_invalid(self):
  37. '''
  38. Store, list, fetch, then flush data
  39. '''
  40. # Store the data
  41. ret = self.run_run_plus(
  42. 'cache.store',
  43. )
  44. # Make sure we can see the new key
  45. expected = 'Passed invalid arguments:'
  46. self.assertIn(expected, ret['return'])
  47. def test_grains(self):
  48. '''
  49. Test cache.grains
  50. '''
  51. # Store the data
  52. ret = self.run_run_plus(
  53. 'cache.grains',
  54. tgt='minion'
  55. )
  56. self.assertIn('minion', ret['return'])
  57. def test_pillar(self):
  58. '''
  59. Test cache.pillar
  60. '''
  61. # Store the data
  62. ret = self.run_run_plus(
  63. 'cache.pillar',
  64. tgt='minion'
  65. )
  66. self.assertIn('minion', ret['return'])
  67. def test_mine(self):
  68. '''
  69. Test cache.mine
  70. '''
  71. # Store the data
  72. ret = self.run_run_plus(
  73. 'cache.mine',
  74. tgt='minion'
  75. )
  76. self.assertIn('minion', ret['return'])