diff --git a/src/drd/cli/ask_handler.py b/src/drd/cli/ask_handler.py index 2887155..8552420 100644 --- a/src/drd/cli/ask_handler.py +++ b/src/drd/cli/ask_handler.py @@ -36,7 +36,7 @@ def handle_ask_command(ask, file, debug): suggestion = suggest_file_alternative(file_path, project_metadata) print_info(f"Suggestion: {suggestion}") user_input = click.prompt( - "Do you want to proceed without this file? (y/n)", type=str) + "Do you want to proceed without this file?", type=str) if user_input.lower() != 'y': return diff --git a/src/drd/cli/monitor/error_resolver.py b/src/drd/cli/monitor/error_resolver.py index 9e15592..c3ab17f 100644 --- a/src/drd/cli/monitor/error_resolver.py +++ b/src/drd/cli/monitor/error_resolver.py @@ -62,7 +62,7 @@ def monitoring_handle_error_with_dravid(error, line, monitor): print_command_details(fix_commands) user_input = monitor.get_user_input( - "Do you want to proceed with this fix? You will be able to stop anytime during the step. [y/N]: " + "Do you want to proceed with this fix? You will be able to stop anytime during the step. " ) if user_input.lower() == 'y': diff --git a/src/drd/cli/monitor/main.py b/src/drd/cli/monitor/main.py index fdff347..7766d30 100644 --- a/src/drd/cli/monitor/main.py +++ b/src/drd/cli/monitor/main.py @@ -6,7 +6,6 @@ def run_dev_server_with_monitoring(command: str): - print_info("Starting server monitor...") error_handlers = { r"(?:Cannot find module|Module not found|ImportError|No module named)": handle_module_not_found, r"(?:SyntaxError|Expected|Unexpected token)": handle_syntax_error, @@ -16,7 +15,7 @@ def run_dev_server_with_monitoring(command: str): monitor = DevServerMonitor(current_dir, error_handlers, command) try: monitor.start() - print_info("Server monitor started. Press Ctrl+C to stop.") + print_info("šŸ‘“ server monitor started. Press Ctrl+C to stop.") while not monitor.should_stop.is_set(): pass print_info("Server monitor has ended.") diff --git a/src/drd/cli/monitor/output_monitor.py b/src/drd/cli/monitor/output_monitor.py index 6cdecd1..5adf7cc 100644 --- a/src/drd/cli/monitor/output_monitor.py +++ b/src/drd/cli/monitor/output_monitor.py @@ -2,7 +2,7 @@ import threading import time import select -from ...utils import print_info, print_error +from ...utils import print_info, print_error, print_prompt MAX_RETRIES = 3 @@ -80,7 +80,8 @@ def _check_idle_state(self): if (time_since_last_output > 5 and not self.idle_prompt_shown and not self.monitor.processing_input.is_set()): - print_info("\nNo more tasks to auto-process. What can I do next?") + print_prompt( + "\nNo more tasks to auto-process. What can I do next?") self._show_options() self.idle_prompt_shown = True diff --git a/src/drd/cli/monitor/server_monitor.py b/src/drd/cli/monitor/server_monitor.py index 104e047..98d0cec 100644 --- a/src/drd/cli/monitor/server_monitor.py +++ b/src/drd/cli/monitor/server_monitor.py @@ -3,7 +3,7 @@ from queue import Queue from .input_handler import InputHandler from .output_monitor import OutputMonitor -from ...utils import print_info, print_success, print_error +from ...utils import print_info, print_success, print_error, print_header, print_prompt MAX_RETRIES = 3 @@ -26,7 +26,8 @@ def __init__(self, project_dir: str, error_handlers: dict, command: str): def start(self): self.should_stop.clear() self.restart_requested.clear() - print_info(f"Starting server with command: {self.command}") + print_header( + f"Starting Dravid AI along with your process/server: {self.command}") try: self.process = start_process(self.command, self.project_dir) self.output_monitor.start() @@ -41,7 +42,7 @@ def stop(self): if self.process: self.process.terminate() self.process.wait() - print_info("Server monitor stopped.") + print_prompt("Server monitor stopped.") def request_restart(self): self.restart_requested.set() diff --git a/src/drd/cli/query/dynamic_command_handler.py b/src/drd/cli/query/dynamic_command_handler.py index 15cdbb5..021b3f7 100644 --- a/src/drd/cli/query/dynamic_command_handler.py +++ b/src/drd/cli/query/dynamic_command_handler.py @@ -12,11 +12,8 @@ def execute_commands(commands, executor, metadata_manager, is_fix=False, debug=F for i, cmd in enumerate(commands, 1): step_description = "fix" if is_fix else "command" - print_step(i, total_steps, - f"Processing {cmd['type']} {step_description}...") if cmd['type'] == 'explanation': - print_info(f"Explanation: {cmd['content']}") all_outputs.append( f"Step {i}/{total_steps}: Explanation - {cmd['content']}") else: @@ -49,7 +46,6 @@ def execute_commands(commands, executor, metadata_manager, is_fix=False, debug=F def handle_shell_command(cmd, executor): - print_info(f"Executing shell command: {cmd['command']}") output = executor.execute_shell_command(cmd['command']) if isinstance(output, str) and output.startswith("Skipping"): print_info(output) @@ -63,8 +59,6 @@ def handle_shell_command(cmd, executor): def handle_file_operation(cmd, executor, metadata_manager): - print_info( - f"Performing file operation: {cmd['operation']} on {cmd['filename']}") operation_performed = executor.perform_file_operation( cmd['operation'], cmd['filename'], @@ -133,8 +127,8 @@ def handle_error_with_dravid(error, cmd, executor, metadata_manager, depth=0, pr previous_context, cmd, error_type, error_message, error_trace, project_context ) - print_info("Sending error information to dravid for analysis...") - print_info("LLM calls to be made: 1") + print_info( + "šŸ Sending error information to dravid for analysis(1 LLM call)...\n") try: fix_commands = call_dravid_api( @@ -143,8 +137,8 @@ def handle_error_with_dravid(error, cmd, executor, metadata_manager, depth=0, pr print_error(f"Error parsing dravid's response: {str(e)}") return False - print_info("dravid's suggested fix:") - print_info("Applying dravid's suggested fix...") + print_info("šŸ©ŗ Dravid's suggested fix:", indent=2) + print_info("šŸ”Ø Applying dravid's suggested fix...", indent=2) fix_applied, step_completed, error_message, all_outputs = execute_commands( fix_commands, executor, metadata_manager, is_fix=True, debug=debug @@ -152,13 +146,11 @@ def handle_error_with_dravid(error, cmd, executor, metadata_manager, depth=0, pr if fix_applied: print_success("All fix steps successfully applied.") - print_info("Fix application details:") click.echo(all_outputs) return True else: print_error(f"Failed to apply the fix at step {step_completed}.") print_error(f"Error message: {error_message}") - print_info("Fix application details:") click.echo(all_outputs) return handle_error_with_dravid( diff --git a/src/drd/cli/query/main.py b/src/drd/cli/query/main.py index ebb9e57..428abe5 100644 --- a/src/drd/cli/query/main.py +++ b/src/drd/cli/query/main.py @@ -3,18 +3,18 @@ from ...utils.step_executor import Executor from ...metadata.project_metadata import ProjectMetadataManager from .dynamic_command_handler import handle_error_with_dravid, execute_commands -from ...utils import print_error, print_success, print_info, print_debug, print_warning, run_with_loader +from ...utils import print_error, print_success, print_info, print_debug, print_warning, print_step, print_header, run_with_loader from ...utils.file_utils import get_file_content, fetch_project_guidelines, is_directory_empty from .file_operations import get_files_to_modify from ...utils.parser import parse_dravid_response def execute_dravid_command(query, image_path, debug, instruction_prompt, warn=None): - print_info("Starting Dravid CLI tool..") + print_header("Starting Dravid AI ...") + if warn: - print_warning("Please make sure you are in a fresh directory.") - print_warning( - "If it is an existing project, please ensure you're in a git branch") + print_warning("Please ensure you review and commit(git) changes") + print("\n") executor = Executor() metadata_manager = ProjectMetadataManager(executor.current_dir) @@ -23,27 +23,27 @@ def execute_dravid_command(query, image_path, debug, instruction_prompt, warn=No project_context = metadata_manager.get_project_context() if project_context: - print_info("Identifying related files to the query...") - print_info("LLM calls to be made: 1") + print_info("šŸ” Identifying related files to the query...", indent=2) + print_info("(1 LLM call)", indent=4) files_to_modify = run_with_loader( lambda: get_files_to_modify(query, project_context), "Analyzing project files" ) print_info( - f"Found {len(files_to_modify)} potentially relevant files.") + f"Found {len(files_to_modify)} potentially relevant files.", indent=4) if debug: - print_info("Possible files to be modified:") + print_info("Possible files to be modified:", indent=4) for file in files_to_modify: - print(f" - {file}") + print_info(f" - {file}", indent=6) - print_info("Reading file contents...") + print_info("šŸ“‚ Reading file contents...", indent=2) file_contents = {} for file in files_to_modify: content = get_file_content(file) if content: file_contents[file] = content - print_info(f" - Read content of {file}") + print_info(f" - Read content of {file}", indent=4) project_guidelines = fetch_project_guidelines(executor.current_dir) file_context = "\n".join( @@ -52,49 +52,45 @@ def execute_dravid_command(query, image_path, debug, instruction_prompt, warn=No else: is_empty = is_directory_empty(executor.current_dir) print_info( - "No current project context found. Will create a new project in the current directory.") + "No current project context found. Will create a new project in the current directory.", indent=2) full_query = f"User query: {query}" + full_query = f"Current directory is {'empty' if is_empty else 'not empty'}.\n\nUser query: {query}" - print_info("Preparing to send query to LLM...") + print_info("šŸ’” Preparing to send query to LLM...", indent=2) if image_path: - print_info(f"Processing image: {image_path}") - print_info("LLM calls to be made: 1") + print_info(f"Processing image: {image_path}", indent=4) + print_info("(1 LLM call)", indent=4) commands = run_with_loader( lambda: call_dravid_vision_api( full_query, image_path, include_context=True, instruction_prompt=instruction_prompt), "Analyzing image and generating response" ) else: - print_info("Streaming response from LLM...") - print_info("LLM calls to be made: 1") + print_info("šŸ’¬ Streaming response from LLM...", indent=2) + print_info("(1 LLM call)", indent=4) xml_result = stream_dravid_api( full_query, include_context=True, instruction_prompt=instruction_prompt, print_chunk=False) commands = parse_dravid_response(xml_result) - # return None if debug: print_debug(f"Received {len(commands)} new command(s)") if not commands: print_error( - "Failed to parse Claude's response or no commands to execute.") - print("Actual result:", xml_result) + "Failed to parse LLM's response or no commands to execute.") + print_debug("Actual result: " + str(xml_result)) return - print_info( - f"Parsed {len(commands)} commands from Claude's response.") - - # Execute commands using the new execute_commands function success, step_completed, error_message, all_outputs = execute_commands( commands, executor, metadata_manager, debug=debug) if not success: - print_error(f"Failed to execute command at step {step_completed}.") + print_error( + f"Failed to execute command at step {step_completed}.") print_error(f"Error message: {error_message}") print_info("Attempting to fix the error...") if handle_error_with_dravid(Exception(error_message), commands[step_completed-1], executor, metadata_manager, debug=debug): print_info( - "Fix applied successfully. Continuing with the remaining commands.") - # Re-execute the remaining commands + "Fix applied successfully. Continuing with the remaining commands.", indent=2) remaining_commands = commands[step_completed:] success, _, error_message, additional_outputs = execute_commands( remaining_commands, executor, metadata_manager, debug=debug) @@ -103,10 +99,10 @@ def execute_dravid_command(query, image_path, debug, instruction_prompt, warn=No print_error( "Unable to fix the error. Skipping this command and continuing with the next.") - print_info("Execution details:") + print_info("Execution details:", indent=2) click.echo(all_outputs) - print_success("Dravid CLI tool execution completed.") + print_success("Dravid CLI Tool execution completed.") except Exception as e: print_error(f"An unexpected error occurred: {str(e)}") if debug: diff --git a/src/drd/utils/__init__.py b/src/drd/utils/__init__.py index efb15f1..c199edf 100644 --- a/src/drd/utils/__init__.py +++ b/src/drd/utils/__init__.py @@ -5,6 +5,8 @@ print_step, print_debug, print_warning, + print_header, + print_prompt ) from .loader import Loader, run_with_loader __all__ = [ @@ -15,5 +17,7 @@ 'print_debug', 'print_warning', 'Loader', - 'run_with_loader' + 'run_with_loader', + 'print_header', + 'print_prompt' ] diff --git a/src/drd/utils/pretty_print_stream.py b/src/drd/utils/pretty_print_stream.py index c596d57..a9ac6fc 100644 --- a/src/drd/utils/pretty_print_stream.py +++ b/src/drd/utils/pretty_print_stream.py @@ -52,7 +52,7 @@ def pretty_print_xml_stream(chunk, state): if operation_match and filename_match: operation = operation_match.group(1).strip() filename = filename_match.group(1).strip() - click.echo(click.style("\nFile Operation:", + click.echo(click.style("\nšŸ“‚ File Operation:", fg="yellow", bold=True), nl=False) click.echo(f" {operation} {filename}") @@ -63,7 +63,7 @@ def pretty_print_xml_stream(chunk, state): if cdata_end != -1: cdata_content = step_content[cdata_start+9:cdata_end] click.echo(click.style( - "\nFile Content:", fg="cyan", bold=True)) + "\nšŸ“„ File Content:", fg="cyan", bold=True)) click.echo(cdata_content) elif step_type == 'shell': command_match = re.search( diff --git a/src/drd/utils/step_executor.py b/src/drd/utils/step_executor.py index 07b9705..3f9fea0 100644 --- a/src/drd/utils/step_executor.py +++ b/src/drd/utils/step_executor.py @@ -58,7 +58,7 @@ def perform_file_operation(self, operation, filename, content=None, force=False) confirmation_box = create_confirmation_box( filename, f"File operation is being carried out outside of the project directory. {operation.lower()} this file") print(confirmation_box) - if not click.confirm(f"{Fore.YELLOW}Confirm {operation.lower()} [y/N]:{Style.RESET_ALL}", default=False): + if not click.confirm(f"{Fore.YELLOW}Confirm {operation.lower()} :{Style.RESET_ALL}", default=False): print_info(f"File {operation.lower()} cancelled by user.") return "Skipping this step" @@ -73,7 +73,7 @@ def perform_file_operation(self, operation, filename, content=None, force=False) preview = preview_file_changes( operation, filename, new_content=content) print(preview) - if click.confirm(f"{Fore.YELLOW}Confirm creation [y/N]:{Style.RESET_ALL}", default=False): + if click.confirm(f"{Fore.YELLOW}Confirm creation {Style.RESET_ALL}", default=False): with open(full_path, 'w') as f: f.write(content) print_success(f"File created successfully: {filename}") @@ -102,7 +102,7 @@ def perform_file_operation(self, operation, filename, content=None, force=False) filename, f"{operation.lower()} this file") print(confirmation_box) - if click.confirm(f"{Fore.YELLOW}Confirm update [y/N]:{Style.RESET_ALL}", default=False): + if click.confirm(f"{Fore.YELLOW}Confirm update {Style.RESET_ALL}", default=False): with open(full_path, 'w') as f: f.write(updated_content) print_success(f"File updated successfully: {filename}") @@ -126,7 +126,7 @@ def perform_file_operation(self, operation, filename, content=None, force=False) confirmation_box = create_confirmation_box( filename, f"{operation.lower()} this file") print(confirmation_box) - if click.confirm(f"{Fore.YELLOW}Confirm deletion [y/N]:{Style.RESET_ALL}", default=False): + if click.confirm(f"{Fore.YELLOW}Confirm deletion {Style.RESET_ALL}", default=False): try: os.remove(full_path) print_success(f"File deleted successfully: {filename}") @@ -171,13 +171,10 @@ def execute_shell_command(self, command, timeout=300): # 5 minutes timeout command, "execute this command") print(confirmation_box) - if not click.confirm(f"{Fore.YELLOW}Confirm execution [y/N]:{Style.RESET_ALL}", default=False): + if not click.confirm(f"{Fore.YELLOW}Confirm execution {Style.RESET_ALL}", default=False): print_info("Command execution cancelled by user.") return 'Skipping this step...' - click.echo( - f"{Fore.YELLOW}Executing shell command: {command}{Style.RESET_ALL}") - if command.strip().startswith(('cd', 'chdir')): return self._handle_cd_command(command) elif command.strip().startswith(('source', '.')): diff --git a/src/drd/utils/utils.py b/src/drd/utils/utils.py index 817e60a..b63c7e9 100644 --- a/src/drd/utils/utils.py +++ b/src/drd/utils/utils.py @@ -1,21 +1,22 @@ import click from colorama import Fore, Style, Back -import json -import os - -METADATA_FILE = 'drd.json' +import shutil def print_error(message): click.echo(f"{Fore.RED}āœ˜ {message}{Style.RESET_ALL}") +def print_prompt(message, indent=0): + click.echo(f"{' ' * indent}{Fore.MAGENTA}{message}{Style.RESET_ALL}") + + def print_success(message): click.echo(f"{Fore.GREEN}āœ” {message}{Style.RESET_ALL}") -def print_info(message): - click.echo(f"{Fore.YELLOW}ā„¹ {message}{Style.RESET_ALL}") +def print_info(message, indent=0): + click.echo(f"{' ' * indent}{Fore.BLUE} {message}{Style.RESET_ALL}") def print_warning(message): @@ -31,20 +32,27 @@ def print_step(step_number, total_steps, message): f"{Fore.CYAN}[{step_number}/{total_steps}] {message}{Style.RESET_ALL}") -def create_confirmation_box(message, action): - box_width = len(message) + 4 - box_top = f"ā•”{'ā•' * box_width}ā•—" - box_bottom = f"ā•š{'ā•' * box_width}ā•" - box_content = f"ā•‘ {message} ā•‘" +def create_confirmation_box(command, action): + terminal_width = shutil.get_terminal_size().columns + # Max width of 60 or terminal width - 4 + box_width = min(terminal_width - 4, 60) + + # Center the title + title = "Confirmation" + title_line = f"| {title.center(box_width - 2)} |" + + command_line = f"| {command.center(box_width - 2)} |" + action_line = f"| {action.center(box_width - 2)} |" confirmation_box = f""" -{Fore.YELLOW}{box_top} -ā•‘ {Back.RED}{Fore.WHITE}CONFIRMATION REQUIRED{Style.RESET_ALL}{Fore.YELLOW} ā•‘ -{box_content} -ā• {'ā•' * box_width}ā•£ -ā•‘ Do you want to {action}? ā•‘ -{box_bottom}{Style.RESET_ALL} +{Fore.CYAN}{' ' * ((terminal_width - box_width) // 2)}ā”Œ{'ā”€' * box_width}ā” +{' ' * ((terminal_width - box_width) // 2)}{title_line} +{' ' * ((terminal_width - box_width) // 2)}|{' ' * box_width}| +{' ' * ((terminal_width - box_width) // 2)}{command_line} +{' ' * ((terminal_width - box_width) // 2)}{action_line} +{' ' * ((terminal_width - box_width) // 2)}ā””{'ā”€' * box_width}ā”˜{Style.RESET_ALL} """ + return confirmation_box @@ -54,10 +62,10 @@ def print_command_details(commands): print_info(f"Command {index} - Type: {cmd_type}") if cmd_type == 'shell': - print_info(f" Command: {cmd.get('command', 'N/A')}") + print_info(f" Command: {cmd.get('command', 'N/A')}", indent=2) elif cmd_type == 'explanation': - print_info(f" Explanation: {cmd.get('content', 'N/A')}") + print_info(f" Explanation: {cmd.get('content', 'N/A')}", indent=2) elif cmd_type == 'file': operation = cmd.get('operation', 'N/A') @@ -65,22 +73,31 @@ def print_command_details(commands): content_preview = cmd.get('content', 'N/A') if len(content_preview) > 50: content_preview = content_preview[:50] + "..." - print_info(f" Operation: {operation}") - print_info(f" Filename: {filename}") - print_info(f" Content: {content_preview}") + print_info(f" Operation: {operation}", indent=2) + print_info(f" Filename: {filename}", indent=2) + print_info(f" Content: {content_preview}", indent=2) elif cmd_type == 'metadata': operation = cmd.get('operation', 'N/A') - print_info(f" Operation: {operation}") + print_info(f" Operation: {operation}", indent=2) if operation == 'UPDATE_DEV_SERVER': print_info( - f" Start Command: {cmd.get('start_command', 'N/A')}") - print_info(f" Framework: {cmd.get('framework', 'N/A')}") - print_info(f" Language: {cmd.get('language', 'N/A')}") + f" Start Command: {cmd.get('start_command', 'N/A')}", indent=2) + print_info( + f" Framework: {cmd.get('framework', 'N/A')}", indent=2) + print_info( + f" Language: {cmd.get('language', 'N/A')}", indent=2) elif operation in ['UPDATE_FILE', 'UPDATE']: - print_info(f" Filename: {cmd.get('filename', 'N/A')}") - print_info(f" Language: {cmd.get('language', 'N/A')}") - print_info(f" Description: {cmd.get('description', 'N/A')}") + print_info( + f" Filename: {cmd.get('filename', 'N/A')}", indent=2) + print_info( + f" Language: {cmd.get('language', 'N/A')}", indent=2) + print_info( + f" Description: {cmd.get('description', 'N/A')}", indent=2) else: print_warning(f" Unknown command type: {cmd_type}") + + +def print_header(message): + click.echo(f"\nšŸŽ¾ {Fore.CYAN}{message}{Style.RESET_ALL}\n") diff --git a/tests/cli/monitor/test_output_monitor.py b/tests/cli/monitor/test_output_monitor.py index c449f09..6fb1ff9 100644 --- a/tests/cli/monitor/test_output_monitor.py +++ b/tests/cli/monitor/test_output_monitor.py @@ -14,55 +14,8 @@ def setUp(self): @patch('select.select') @patch('time.time') @patch('drd.cli.monitor.output_monitor.print_info') - def test_idle_state(self, mock_print_info, mock_time, mock_select): - # Setup - self.mock_monitor.should_stop.is_set.side_effect = [ - False] * 10 + [True] - self.mock_monitor.process.poll.return_value = None - self.mock_monitor.processing_input.is_set.return_value = False - self.mock_monitor.process.stdout = MagicMock() - self.mock_monitor.process.stdout.readline.return_value = "" - mock_select.return_value = ([self.mock_monitor.process.stdout], [], []) - - # Create a function to generate increasing time values - start_time = 1000000 # Start with a large value to avoid negative times - - def time_sequence(): - nonlocal start_time - start_time += 1 # Increment by 1 second each time - return start_time - - mock_time.side_effect = time_sequence - - # Capture stdout - captured_output = StringIO() - sys.stdout = captured_output - - # Run - self.output_monitor._monitor_output() - - # Restore stdout - sys.stdout = sys.__stdout__ - - # Print captured output - print("Captured output:") - print(captured_output.getvalue()) - - # Assert - expected_calls = [ - call("\nNo more tasks to auto-process. What can I do next?"), - call("\nAvailable actions:"), - call("1. Give a coding instruction to perform"), - call("2. Process an image (type 'vision')"), - call("3. Exit monitoring mode (type 'exit')"), - call("\nType your choice or command:") - ] - mock_print_info.assert_has_calls(expected_calls, any_order=True) - - @patch('select.select') - @patch('time.time') - @patch('drd.cli.monitor.output_monitor.print_info') - def test_idle_state(self, mock_print_info, mock_time, mock_select): + @patch('drd.cli.monitor.output_monitor.print_prompt') + def test_idle_state(self, mock_print_prompt, mock_print_info, mock_time, mock_select): # Setup self.mock_monitor.should_stop.is_set.side_effect = [ False] * 10 + [True] @@ -88,8 +41,9 @@ def test_idle_state(self, mock_print_info, mock_time, mock_select): print(captured_output.getvalue()) # Assert + mock_print_prompt.assert_called_once_with( + "\nNo more tasks to auto-process. What can I do next?") expected_calls = [ - call("\nNo more tasks to auto-process. What can I do next?"), call("\nAvailable actions:"), call("1. Give a coding instruction to perform"), call("2. Process an image (type 'vision')"), diff --git a/tests/cli/query/test_dynamic_command_handler.py b/tests/cli/query/test_dynamic_command_handler.py index 49fd9df..55cecf0 100644 --- a/tests/cli/query/test_dynamic_command_handler.py +++ b/tests/cli/query/test_dynamic_command_handler.py @@ -56,8 +56,6 @@ def test_handle_shell_command(self, mock_echo, mock_print_success, mock_print_in self.assertEqual(output, "Hello") self.executor.execute_shell_command.assert_called_once_with( 'echo "Hello"') - mock_print_info.assert_called_once_with( - 'Executing shell command: echo "Hello"') mock_print_success.assert_called_once_with( 'Successfully executed: echo "Hello"') mock_echo.assert_called_once_with('Command output:\nHello') @@ -130,8 +128,6 @@ def test_handle_shell_command_skipped(self, mock_echo, mock_print_success, mock_ self.assertEqual(output, "Skipping this step...") self.executor.execute_shell_command.assert_called_once_with( 'echo "Hello"') - mock_print_info.assert_any_call( - 'Executing shell command: echo "Hello"') mock_print_info.assert_any_call("Skipping this step...") mock_print_success.assert_not_called() mock_echo.assert_not_called() diff --git a/tests/cli/query/test_query_main.py b/tests/cli/query/test_query_main.py index 54de375..378e96f 100644 --- a/tests/cli/query/test_query_main.py +++ b/tests/cli/query/test_query_main.py @@ -98,7 +98,7 @@ def test_execute_dravid_command_with_error(self, mock_run_with_loader, mock_get_ "Failed to execute command at step 1.") mock_handle_error.assert_called_once() mock_print_info.assert_any_call( - "Fix applied successfully. Continuing with the remaining commands.") + "Fix applied successfully. Continuing with the remaining commands.", indent=2) @patch('drd.cli.query.main.Executor') @patch('drd.cli.query.main.ProjectMetadataManager') @@ -127,7 +127,8 @@ def test_execute_dravid_command_with_image(self, mock_get_files, mock_run_with_l self.debug, self.instruction_prompt) mock_call_vision_api.assert_called_once() - mock_print_info.assert_any_call(f"Processing image: {self.image_path}") + mock_print_info.assert_any_call( + f"Processing image: {self.image_path}", indent=4) @patch('drd.cli.query.main.Executor') @patch('drd.cli.query.main.ProjectMetadataManager') diff --git a/tests/utils/test_utils.py b/tests/utils/test_utils.py index 437f2a4..1099b54 100644 --- a/tests/utils/test_utils.py +++ b/tests/utils/test_utils.py @@ -39,7 +39,7 @@ def test_print_success(self, mock_echo): def test_print_info(self, mock_echo): print_info("Test info message") mock_echo.assert_called_with( - f"{Fore.YELLOW}ā„¹ Test info message{Style.RESET_ALL}") + f"{Fore.BLUE} Test info message{Style.RESET_ALL}") @patch('click.echo') def test_print_warning(self, mock_echo):