test_rabbitmq_user.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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 pytest
  8. # Import Salt Testing libs
  9. from tests.support.case import ModuleCase
  10. from tests.support.mixins import SaltReturnAssertsMixin
  11. @pytest.mark.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)