1
0

test_beacon.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. # -*- coding: utf-8 -*-
  2. '''
  3. Integration tests for the beacon states
  4. '''
  5. from __future__ import absolute_import, print_function, unicode_literals
  6. # Import Salt Testing Libs
  7. from tests.support.case import ModuleCase
  8. from tests.support.mixins import SaltReturnAssertsMixin
  9. class BeaconStateTestCase(ModuleCase, SaltReturnAssertsMixin):
  10. '''
  11. Test beacon states
  12. '''
  13. def setUp(self):
  14. '''
  15. '''
  16. self.run_function('beacons.reset', f_timeout=300)
  17. self.wait_for_all_jobs()
  18. def tearDown(self):
  19. self.run_function('beacons.reset', f_timeout=300)
  20. def test_present_absent(self):
  21. kwargs = {'/': '38%', 'interval': 5}
  22. ret = self.run_state(
  23. 'beacon.present',
  24. name='diskusage',
  25. f_timeout=300,
  26. **kwargs
  27. )
  28. self.assertSaltTrueReturn(ret)
  29. ret = self.run_function('beacons.list',
  30. return_yaml=False,
  31. f_timeout=300)
  32. self.assertTrue('diskusage' in ret)
  33. self.assertTrue({'interval': 5} in ret['diskusage'])
  34. self.assertTrue({'/': '38%'} in ret['diskusage'])
  35. ret = self.run_state(
  36. 'beacon.absent',
  37. name='diskusage',
  38. f_timeout=300
  39. )
  40. self.assertSaltTrueReturn(ret)
  41. ret = self.run_function('beacons.list',
  42. return_yaml=False,
  43. f_timeout=300)
  44. self.assertEqual(ret, {'beacons': {}})