test_beacon.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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.mixins import SaltReturnAssertsMixin
  10. import logging
  11. log = logging.getLogger(__name__)
  12. class BeaconStateTestCase(ModuleCase, SaltReturnAssertsMixin):
  13. '''
  14. Test beacon states
  15. '''
  16. def setUp(self):
  17. '''
  18. '''
  19. self.run_function('beacons.reset')
  20. self.wait_for_all_jobs()
  21. def tearDown(self):
  22. self.run_function('beacons.reset')
  23. def test_present_absent(self):
  24. kwargs = {'/': '38%', 'interval': 5}
  25. ret = self.run_state(
  26. 'beacon.present',
  27. name='diskusage',
  28. **kwargs
  29. )
  30. self.assertSaltTrueReturn(ret)
  31. ret = self.run_function('beacons.list', return_yaml=False)
  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. )
  39. self.assertSaltTrueReturn(ret)
  40. ret = self.run_function('beacons.list', return_yaml=False)
  41. self.assertEqual(ret, {'beacons': {}})