Exemplo n.º 1
0
def test_present_absent(docker_cmd_run_all_wrapper):
    """
    Test rabbitmq_vhost.present
    """

    # Clear the user
    ret = rabbitmq_vhost.present("vhost")
    expected = {
        "name": "vhost",
        "result": True,
        "comment": 'Adding vhost "vhost" ...\n',
        "changes": {"old": "", "new": "vhost"},
    }
    assert ret == expected

    # Delete the user
    ret = rabbitmq_vhost.absent("vhost")
    expected = {
        "name": "vhost",
        "result": True,
        "comment": 'Deleting vhost "vhost" ...\n',
        "changes": {"old": "vhost", "new": ""},
    }

    assert ret == expected
Exemplo n.º 2
0
    def test_present(self):
        '''
        Test to ensure the RabbitMQ VHost exists.
        '''
        name = 'virtual_host'

        ret = {'name': name,
               'changes': {'new': 'virtual_host', 'old': ''},
               'result': None,
               'comment': 'Virtual Host \'virtual_host\' will be created.'}

        mock = MagicMock(return_value=False)
        with patch.dict(rabbitmq_vhost.__salt__,
                        {'rabbitmq.vhost_exists': mock}):
            with patch.dict(rabbitmq_vhost.__opts__, {'test': True}):
                self.assertDictEqual(rabbitmq_vhost.present(name), ret)
Exemplo n.º 3
0
    def test_present(self):
        '''
        Test to ensure the RabbitMQ VHost exists.
        '''
        name = 'virtual_host'

        ret = {
            'name': name,
            'changes': {},
            'result': None,
            'comment': 'Creating VHost virtual_host'
        }

        mock = MagicMock(return_value=False)
        with patch.dict(rabbitmq_vhost.__salt__,
                        {'rabbitmq.vhost_exists': mock}):
            with patch.dict(rabbitmq_vhost.__opts__, {'test': True}):
                self.assertDictEqual(rabbitmq_vhost.present(name), ret)
Exemplo n.º 4
0
def test_present():
    """
    Test to ensure the RabbitMQ VHost exists.
    """
    name = "virtual_host"

    ret = {
        "name": name,
        "changes": {
            "new": "virtual_host",
            "old": ""
        },
        "result": None,
        "comment": "Virtual Host 'virtual_host' will be created.",
    }

    mock = MagicMock(return_value=False)
    with patch.dict(rabbitmq_vhost.__salt__, {"rabbitmq.vhost_exists": mock}):
        with patch.dict(rabbitmq_vhost.__opts__, {"test": True}):
            assert rabbitmq_vhost.present(name) == ret