def test_executor_clear(mock_config_path, mock_clear, test_input): mock_config_path.return_value = setup_config_path_for_test() executor = kafkashell.executor.Executor(kafkashell.settings.Settings()) executor.execute(test_input) mock_clear.assert_called_once()
def test_check_for_valid_command_prefix(mock_config_path, mock_cluster_details, test_input, expected): mock_config_path.return_value = setup_config_path_for_test() mock_cluster_details.return_value = test_input executor = kafkashell.executor.Executor(kafkashell.settings.Settings()) assert executor.check_for_valid_command_prefix() == expected
def test_executor(mock_config_path, mock_os_system, test_input, expected): mock_config_path.return_value = setup_config_path_for_test() executor = kafkashell.executor.Executor(kafkashell.settings.Settings()) executor.execute(test_input) mock_os_system.assert_called_once_with(expected)
def test_executor_cluster_select(mock_config_path, mock_print, test_input, expected, selected_cluster): mock_config_path.return_value = setup_config_path_for_test() settings = kafkashell.settings.Settings() executor = kafkashell.executor.Executor(settings) executor.execute(test_input) mock_print.assert_called_once_with(expected) assert settings.cluster == selected_cluster
def test_executor_version(mock_config_path, mock_get_version, mock_print, test_input, expected): mock_config_path.return_value = setup_config_path_for_test() mock_get_version.return_value = expected executor = kafkashell.executor.Executor(kafkashell.settings.Settings()) executor.execute(test_input) mock_get_version.assert_called_once() mock_print.assert_called_once_with(expected)
def test_executor_save(mock_config_path, mock_save_settings, mock_print, test_input): mock_config_path.return_value = setup_config_path_for_test() executor = kafkashell.executor.Executor(kafkashell.settings.Settings()) executor.execute(test_input) mock_save_settings.assert_called_once() mock_print.assert_called_once_with("Saved settings!")
def test_executor_command_file_extension_bat(mock_config_path, mock_os_system, test_input, expected): mock_config_path.return_value = setup_config_path_for_test( "test-file-extension-bat") executor = kafkashell.executor.Executor(kafkashell.settings.Settings()) executor.execute(test_input) mock_os_system.assert_called_once_with(expected)
def test_executor_cluster_describe(mock_config_path, mock_print_cluster, mock_print, test_input, expected, success): mock_config_path.return_value = setup_config_path_for_test() settings = kafkashell.settings.Settings() executor = kafkashell.executor.Executor(settings) executor.execute(test_input) if success: mock_print_cluster.assert_called_once_with(settings.user_config["clusters"][test_input.split(" ")[1]]) else: mock_print.assert_called_once_with(expected)
def test_toolbar(mock_set_next_cluster, mock_set_enable_fuzzy_search, mock_set_enable_help, mock_config_path, mock_get_app): mock_config_path.return_value = setup_config_path_for_test() bindings = kafkashell.bindings.get_bindings(kafkashell.settings.Settings()) assert bindings.bindings is not None for binding in bindings.bindings: binding.handler({}) key = binding.keys[0] if key == "f2": mock_set_next_cluster.assert_called_once() elif key == "f3": mock_set_enable_fuzzy_search.assert_called_once_with(False) elif key == "f9": mock_set_enable_help.assert_called_once_with(False) elif key == "f10": mock_get_app.assert_called_once() mock_get_app.return_value.exit.assert_called_once_with( exception=EOFError)