def test_interactive_function_success(): """Ensure the function is called when it passes inspection.""" def good_function(session): return session.run("who") runner = Bladerunner() mock_hosts = Mock() # we need to mock out the interactive_hosts dict b/c dict.values will # return a new object every time, making the assert_called_once_with fail runner.interactive_hosts = mock_hosts map_mock = patch.object( base.ThreadPoolExecutor, "map", return_value=["totes fake"], ) with patch.object(runner, "setup_interactive") as mock_setup: with map_mock as mock_map: res = runner.run_interactive_function(good_function, "some host") mock_setup.assert_called_once_with("some host") assert mock_map.call_count == 1 mock_map.assert_called_once_with( good_function, mock_hosts.values(), ) assert res == ["totes fake"]
def test_interactive_function_success(): """Ensure the function is called when it passes inspection.""" def good_function(session): return session.run("who") runner = Bladerunner() mock_hosts = Mock() # we need to mock out the interactive_hosts dict b/c dict.values will # return a new object every time, making the assert_called_once_with fail runner.interactive_hosts = mock_hosts map_mock = patch.object( base.ThreadPoolExecutor, "map", return_value=["totes fake"], ) with patch.object(runner, "setup_interactive") as mock_setup: with map_mock as mock_map: res = runner.run_interactive_function(good_function, "some host") mock_setup.assert_called_once_with("some host") assert mock_map.call_count == 1 mock_map.assert_called_once_with( good_function, mock_hosts.values(), ) assert res == ["totes fake"]
def test_interactive_functions(bad_interactive_function): """Ensure the functions are inspected as correct then run with hosts.""" runner = Bladerunner() with pytest.raises(TypeError): runner.run_interactive_function(bad_interactive_function)
def test_interactive_functions(bad_interactive_function): """Ensure the functions are inspected as correct then run with hosts.""" runner = Bladerunner() with pytest.raises(TypeError): runner.run_interactive_function(bad_interactive_function)