def test_disabled(rabbitmq_container): """ Test rabbitmq_plugin.enabled and rabbitmq_plugin_disabled First try to disable the plugin. Second enable the plugin again. Third disable the plugin. """ with patch.object(rabbitmq, "_get_rabbitmq_plugin", mock_get_rabbitmq_plugin): # Try to disable the plugin ret = rabbitmq_plugin.disabled("rabbitmq_auth_backend_http") expected = { "name": "rabbitmq_auth_backend_http", "result": True, "comment": "Plugin 'rabbitmq_auth_backend_http' is already disabled.", "changes": {}, } assert ret == expected # Enable the plugin ret = rabbitmq_plugin.enabled("rabbitmq_auth_backend_http") expected = { "name": "rabbitmq_auth_backend_http", "result": True, "comment": "Plugin 'rabbitmq_auth_backend_http' was enabled.", "changes": { "old": "", "new": "rabbitmq_auth_backend_http" }, } assert ret == expected # Disable the plugin ret = rabbitmq_plugin.disabled("rabbitmq_auth_backend_http") expected = { "name": "rabbitmq_auth_backend_http", "result": True, "comment": "Plugin 'rabbitmq_auth_backend_http' was disabled.", "changes": { "new": "", "old": "rabbitmq_auth_backend_http" }, } assert ret == expected
def test_disabled(self): """ Test to ensure the RabbitMQ plugin is disabled. """ name = "some_plugin" ret = {"name": name, "changes": {}, "result": True, "comment": ""} mock = MagicMock(side_effect=[False, True]) with patch.dict(rabbitmq_plugin.__salt__, {"rabbitmq.plugin_is_enabled": mock}): comment = "Plugin 'some_plugin' is already disabled." ret.update({"comment": comment}) self.assertDictEqual(rabbitmq_plugin.disabled(name), ret) with patch.dict(rabbitmq_plugin.__opts__, {"test": True}): comment = "Plugin 'some_plugin' is set to be disabled." changes = {"new": "", "old": "some_plugin"} ret.update({"comment": comment, "result": None, "changes": changes}) self.assertDictEqual(rabbitmq_plugin.disabled(name), ret)
def test_disabled(self): ''' Test to ensure the RabbitMQ plugin is disabled. ''' name = 'some_plugin' ret = {'name': name, 'changes': {}, 'result': True, 'comment': ''} mock = MagicMock(side_effect=[False, True]) with patch.dict(rabbitmq_plugin.__salt__, {'rabbitmq.plugin_is_enabled': mock}): comt = ('Plugin some_plugin is not enabled') ret.update({'comment': comt}) self.assertDictEqual(rabbitmq_plugin.disabled(name), ret) with patch.dict(rabbitmq_plugin.__opts__, {'test': True}): comt = ('Plugin some_plugin is set to be disabled') ret.update({'comment': comt, 'result': None}) self.assertDictEqual(rabbitmq_plugin.disabled(name), ret)
def test_disabled(self): ''' Test to ensure the RabbitMQ plugin is disabled. ''' name = 'some_plugin' ret = {'name': name, 'changes': {}, 'result': True, 'comment': ''} mock = MagicMock(side_effect=[False, True]) with patch.dict(rabbitmq_plugin.__salt__, {'rabbitmq.plugin_is_enabled': mock}): comt = ('Plugin some_plugin is not enabled') ret.update({'comment': comt}) self.assertDictEqual(rabbitmq_plugin.disabled(name), ret) with patch.dict(rabbitmq_plugin.__opts__, {'test': True}): comt = ('Plugin some_plugin is set to be disabled') ret.update({'comment': comt, 'result': None}) self.assertDictEqual(rabbitmq_plugin.disabled(name), ret)