def test_single_queue_true():
    """Test transactional_update.single"""
    ssh_state_mock = MagicMock()
    ssh_state_mock.return_value = ssh_state_mock
    ssh_state_mock.verify_data.return_value = None

    _create_and_execute_salt_state_mock = MagicMock(return_value="result")
    opts_mock = {
        "hash_type": "md5",
    }
    salt_mock = {
        "saltutil.is_running":
        MagicMock(side_effect=[
            [{
                "fun": "state.running",
                "pid": "4126",
                "jid": "20150325123407204096",
            }],
            [],
        ]),
    }
    get_sls_opts_mock = MagicMock(return_value=opts_mock)
    with patch.dict(tu.__opts__, opts_mock), patch.dict(
            statemod.__salt__, salt_mock
    ), patch("salt.utils.state.get_sls_opts", get_sls_opts_mock), patch(
            "salt.fileclient.get_file_client", MagicMock()
    ), patch("salt.client.ssh.state.SSHState", ssh_state_mock), patch(
            "salt.modules.transactional_update._create_and_execute_salt_state",
            _create_and_execute_salt_state_mock,
    ):
        assert tu.single("pkg.installed", name="emacs", queue=True) == "result"
        _create_and_execute_salt_state_mock.assert_called_once()
    def test_single_queue_true(self, get_sls_opts, SSHState,
                               _create_and_execute_salt_state):
        """Test transactional_update.single"""
        SSHState.return_value = SSHState
        SSHState.verify_data.return_value = None

        _create_and_execute_salt_state.return_value = "result"
        opts_mock = {
            "hash_type": "md5",
        }
        salt_mock = {
            "saltutil.is_running":
            MagicMock(side_effect=[
                [{
                    "fun": "state.running",
                    "pid": "4126",
                    "jid": "20150325123407204096",
                }],
                [],
            ]),
        }
        get_sls_opts.return_value = opts_mock
        with patch.dict(tu.__opts__,
                        opts_mock), patch.dict(statemod.__salt__, salt_mock):
            assert tu.single("pkg.installed", name="emacs",
                             queue=True) == "result"
            _create_and_execute_salt_state.assert_called_once()
    def test_single_queue_false_failing(self, get_sls_opts, SSHState,
                                        _create_and_execute_salt_state):
        """Test transactional_update.single"""
        SSHState.return_value = SSHState
        SSHState.verify_data.return_value = None

        _create_and_execute_salt_state.return_value = "result"
        opts_mock = {
            "hash_type": "md5",
        }
        salt_mock = {
            "saltutil.is_running":
            MagicMock(side_effect=[
                [{
                    "fun": "state.running",
                    "pid": "4126",
                    "jid": "20150325123407204096",
                }],
                [],
            ]),
        }
        get_sls_opts.return_value = opts_mock
        with patch.dict(tu.__opts__,
                        opts_mock), patch.dict(statemod.__salt__, salt_mock):
            assert tu.single("pkg.installed", name="emacs", queue=False) == [
                'The function "state.running" is running as PID 4126 and was started at 2015, Mar 25 12:34:07.204096 with jid 20150325123407204096'
            ]
Beispiel #4
0
def test_single():
    """Test transactional_update.single"""
    salt_mock = {
        "saltutil.is_running": MagicMock(return_value=[]),
    }
    with patch.dict(statemod.__salt__,
                    salt_mock), patch("salt.modules.transactional_update.call",
                                      MagicMock(return_value="result")):
        assert tu.single("pkg.installed", name="emacs") == "result"
    def test_single(self, get_sls_opts, SSHState, _create_and_execute_salt_state):
        """Test transactional_update.single"""
        SSHState.return_value = SSHState
        SSHState.verify_data.return_value = None

        _create_and_execute_salt_state.return_value = "result"
        opts_mock = {
            "hash_type": "md5",
        }
        get_sls_opts.return_value = opts_mock
        with patch.dict(tu.__opts__, opts_mock):
            assert tu.single("pkg.installed", name="emacs") == "result"
            _create_and_execute_salt_state.assert_called_once()
Beispiel #6
0
def test_single_queue_true():
    """Test transactional_update.single"""
    salt_mock = {
        "saltutil.is_running":
        MagicMock(side_effect=[
            [{
                "fun": "state.running",
                "pid": "4126",
                "jid": "20150325123407204096",
            }],
            [],
        ]),
    }
    with patch.dict(statemod.__salt__,
                    salt_mock), patch("salt.modules.transactional_update.call",
                                      MagicMock(return_value="result")):
        assert tu.single("pkg.installed", name="emacs", queue=True) == "result"
Beispiel #7
0
def test_single_queue_false_failing():
    """Test transactional_update.single"""
    salt_mock = {
        "saltutil.is_running":
        MagicMock(side_effect=[
            [{
                "fun": "state.running",
                "pid": "4126",
                "jid": "20150325123407204096",
            }],
            [],
        ]),
    }
    with patch.dict(statemod.__salt__,
                    salt_mock), patch("salt.modules.transactional_update.call",
                                      MagicMock(return_value="result")):
        assert tu.single("pkg.installed", name="emacs", queue=False) == [
            'The function "state.running" is running as PID 4126 and was started at 2015, Mar 25 12:34:07.204096 with jid 20150325123407204096'
        ]
def test_single():
    """Test transactional_update.single"""
    ssh_state_mock = MagicMock()
    ssh_state_mock.return_value = ssh_state_mock
    ssh_state_mock.verify_data.return_value = None

    _create_and_execute_salt_state_mock = MagicMock(return_value="result")
    opts_mock = {
        "hash_type": "md5",
    }
    salt_mock = {
        "saltutil.is_running": MagicMock(return_value=[]),
    }
    get_sls_opts_mock = MagicMock(return_value=opts_mock)
    with patch.dict(tu.__opts__, opts_mock), patch.dict(
            statemod.__salt__, salt_mock
    ), patch("salt.utils.state.get_sls_opts", get_sls_opts_mock), patch(
            "salt.fileclient.get_file_client", MagicMock()
    ), patch("salt.client.ssh.state.SSHState", ssh_state_mock), patch(
            "salt.modules.transactional_update._create_and_execute_salt_state",
            _create_and_execute_salt_state_mock,
    ):
        assert tu.single("pkg.installed", name="emacs") == "result"
        _create_and_execute_salt_state_mock.assert_called_once()