1
0

test_beacon.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. # -*- coding: utf-8 -*-
  2. '''
  3. Integration tests for the beacon states
  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 ModuleCase
  9. from tests.support.helpers import destructiveTest
  10. from tests.support.mixins import SaltReturnAssertsMixin
  11. import logging
  12. log = logging.getLogger(__name__)
  13. @destructiveTest
  14. class BeaconStateTestCase(ModuleCase, SaltReturnAssertsMixin):
  15. '''
  16. Test beacon states
  17. '''
  18. def setUp(self):
  19. '''
  20. '''
  21. self.run_function('beacons.reset', f_timeout=300)
  22. def tearDown(self):
  23. self.run_function('beacons.reset', f_timeout=300)
  24. def test_present_absent(self):
  25. kwargs = {'/': '38%', 'interval': 5}
  26. ret = self.run_state(
  27. 'beacon.present',
  28. name='diskusage',
  29. f_timeout=300,
  30. **kwargs
  31. )
  32. self.assertSaltTrueReturn(ret)
  33. ret = self.run_function('beacons.list',
  34. return_yaml=False,
  35. f_timeout=300)
  36. self.assertTrue('diskusage' in ret)
  37. self.assertTrue({'interval': 5} in ret['diskusage'])
  38. self.assertTrue({'/': '38%'} in ret['diskusage'])
  39. ret = self.run_state(
  40. 'beacon.absent',
  41. name='diskusage',
  42. f_timeout=300
  43. )
  44. self.assertSaltTrueReturn(ret)
  45. ret = self.run_function('beacons.list',
  46. return_yaml=False,
  47. f_timeout=300)
  48. self.assertEqual(ret, {'beacons': {}})