1
0

test_rabbitmq_user.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # -*- coding: utf-8 -*-
  2. '''
  3. Tests for the rabbitmq state
  4. '''
  5. # Import python libs
  6. from __future__ import absolute_import, unicode_literals, print_function
  7. # Import Salt Testing libs
  8. from tests.support.case import ModuleCase
  9. from tests.support.helpers import skip_if_not_root
  10. from tests.support.mixins import SaltReturnAssertsMixin
  11. @skip_if_not_root
  12. class RabbitUserTestCase(ModuleCase, SaltReturnAssertsMixin):
  13. '''
  14. Validate the rabbitmq user states.
  15. '''
  16. def setUp(self):
  17. super(RabbitUserTestCase, self).setUp()
  18. rabbit_installed = self.run_function('cmd.has_exec', ['rabbitmqctl'])
  19. if not rabbit_installed:
  20. self.skipTest('rabbitmq-server not installed')
  21. def test_present(self):
  22. '''
  23. rabbitmq_user.present null_name
  24. '''
  25. ret = self.run_state(
  26. 'rabbitmq_user.present', name='null_name', test=True
  27. )
  28. self.assertSaltFalseReturn(ret)
  29. self.assertInSaltComment('User \'null_name\' is set to be created', ret)
  30. def absent(self):
  31. '''
  32. rabbitmq_user.absent null_name
  33. '''
  34. ret = self.run_state(
  35. 'rabbitmq_user.absent', name='null_name', test=True
  36. )
  37. self.assertSaltFalseReturn(ret)