salt/tests/integration/states/test_rabbitmq_user.py

44 lines
1.2 KiB
Python
Raw Normal View History

# -*- coding: utf-8 -*-
'''
Tests for the rabbitmq state
'''
# Import python libs
from __future__ import absolute_import
# Import Salt Testing libs
from tests.support.case import ModuleCase
from tests.support.helpers import skip_if_not_root
2017-04-02 16:09:47 +00:00
from tests.support.mixins import SaltReturnAssertsMixin
@skip_if_not_root
class RabbitUserTestCase(ModuleCase, SaltReturnAssertsMixin):
'''
2012-10-19 15:07:31 +00:00
Validate the rabbitmq user states.
'''
def setUp(self):
super(RabbitUserTestCase, self).setUp()
rabbit_installed = self.run_function('cmd.has_exec', ['rabbitmqctl'])
if not rabbit_installed:
self.skipTest('rabbitmq-server not installed')
def test_present(self):
'''
2012-10-19 15:07:31 +00:00
rabbitmq_user.present null_name
'''
ret = self.run_state(
'rabbitmq_user.present', name='null_name', test=True
)
2012-12-07 19:05:19 +00:00
self.assertSaltFalseReturn(ret)
self.assertInSaltComment('User \'null_name\' is set to be created', ret)
2012-10-19 15:07:31 +00:00
def absent(self):
'''
rabbitmq_user.absent null_name
'''
ret = self.run_state(
'rabbitmq_user.absent', name='null_name', test=True
)
self.assertSaltFalseReturn(ret)