1
0

test_rabbitmq_user.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # -*- coding: utf-8 -*-
  2. """
  3. Tests for the rabbitmq state
  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 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("rabbitmq_user.present", name="null_name", test=True)
  26. self.assertSaltFalseReturn(ret)
  27. self.assertInSaltComment("User 'null_name' is set to be created", ret)
  28. def absent(self):
  29. """
  30. rabbitmq_user.absent null_name
  31. """
  32. ret = self.run_state("rabbitmq_user.absent", name="null_name", test=True)
  33. self.assertSaltFalseReturn(ret)