1
0

test_rabbitmq_user.py 1.1 KB

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