test_beacon.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. def tearDown(self):
  18. self.run_function('beacons.reset', f_timeout=300)
  19. def test_present_absent(self):
  20. kwargs = {'/': '38%', 'interval': 5}
  21. ret = self.run_state(
  22. 'beacon.present',
  23. name='diskusage',
  24. f_timeout=300,
  25. **kwargs
  26. )
  27. self.assertSaltTrueReturn(ret)
  28. ret = self.run_function('beacons.list',
  29. return_yaml=False,
  30. f_timeout=300)
  31. self.assertTrue('diskusage' in ret)
  32. self.assertTrue({'interval': 5} in ret['diskusage'])
  33. self.assertTrue({'/': '38%'} in ret['diskusage'])
  34. ret = self.run_state(
  35. 'beacon.absent',
  36. name='diskusage',
  37. f_timeout=300
  38. )
  39. self.assertSaltTrueReturn(ret)
  40. ret = self.run_function('beacons.list',
  41. return_yaml=False,
  42. f_timeout=300)
  43. self.assertEqual(ret, {'beacons': {}})