def test_highstate_queue_true(): """Test transactional_update.highstage""" transactional_update_highstate_mock = MagicMock() transactional_update_highstate_mock.return_value = ( transactional_update_highstate_mock) _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.modules.transactional_update.TransactionalUpdateHighstate", transactional_update_highstate_mock, ), patch( "salt.modules.transactional_update._create_and_execute_salt_state", _create_and_execute_salt_state_mock, ): assert tu.highstate(queue=True) == "result" _create_and_execute_salt_state_mock.assert_called_once()
def test_highstate(): """Test transactional_update.highstage""" transactional_update_highstate_mock = MagicMock() transactional_update_highstate_mock.return_value = ( transactional_update_highstate_mock) _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.modules.transactional_update.TransactionalUpdateHighstate", transactional_update_highstate_mock, ), patch( "salt.modules.transactional_update._create_and_execute_salt_state", _create_and_execute_salt_state_mock, ): assert tu.highstate() == "result" _create_and_execute_salt_state_mock.assert_called_once()
def test_highstate_queue_false_failing( self, get_sls_opts, get_file_client, TransactionalUpdateHighstate, _create_and_execute_salt_state, ): """Test transactional_update.highstage""" TransactionalUpdateHighstate.return_value = TransactionalUpdateHighstate _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.highstate(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_highstate_queue_true( self, get_sls_opts, get_file_client, TransactionalUpdateHighstate, _create_and_execute_salt_state, ): """Test transactional_update.highstage""" TransactionalUpdateHighstate.return_value = TransactionalUpdateHighstate _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.highstate(queue=True) == "result" _create_and_execute_salt_state.assert_called_once()
def test_highstate(): """Test transactional_update.highstage""" 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.highstate() == "result"
def test_highstate_queue_true(): """Test transactional_update.highstage""" 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.highstate(queue=True) == "result"
def test_highstate( self, get_sls_opts, get_file_client, SSHHighState, _create_and_execute_salt_state, ): """Test transactional_update.highstage""" SSHHighState.return_value = SSHHighState _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.highstate() == "result" _create_and_execute_salt_state.assert_called_once()
def test_highstate_queue_false_failing(): """Test transactional_update.highstage""" 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.highstate(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_highstate( self, get_sls_opts, get_file_client, TransactionalUpdateHighstate, _create_and_execute_salt_state, ): """Test transactional_update.highstage""" TransactionalUpdateHighstate.return_value = TransactionalUpdateHighstate _create_and_execute_salt_state.return_value = "result" opts_mock = { "hash_type": "md5", } salt_mock = { "saltutil.is_running": MagicMock(return_value=[]), } get_sls_opts.return_value = opts_mock with patch.dict(tu.__opts__, opts_mock), patch.dict(statemod.__salt__, salt_mock): assert tu.highstate() == "result" _create_and_execute_salt_state.assert_called_once()
def test_highstate_queue_false_failing(): """Test transactional_update.highstage""" transactional_update_highstate_mock = MagicMock() transactional_update_highstate_mock.return_value = ( transactional_update_highstate_mock) _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.modules.transactional_update.TransactionalUpdateHighstate", transactional_update_highstate_mock, ), patch( "salt.modules.transactional_update._create_and_execute_salt_state", _create_and_execute_salt_state_mock, ): assert tu.highstate(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' ] _create_and_execute_salt_state_mock.assert_not_called()