Files
cleveragents-core/tests/features/cli_coverage.feature

342 lines
15 KiB
Gherkin

Feature: CLI Module Coverage
As a developer
I want to test all functionality in the CLI module
So that we achieve 90%+ code coverage for the cli.py file
Background:
Given I have a clean test environment for CLI
# Main command group tests
Scenario: Test main command group initialization
Given I have the CLI command group
When I initialize the main command group
Then the main command group should be available
And the version option should be available
# Run command tests
Scenario: Test run command - successful execution
Given I have a valid configuration file
And I have a prompt for the agent
When I run the run command with valid parameters
Then the command should execute successfully
And the result should be output
Scenario: Test run command - with output file
Given I have a valid configuration file
And I have a prompt for the agent
And I have an output file path
When I run the run command with output file
Then the command should execute successfully
And the result should be written to the output file
And a confirmation message should be displayed
Scenario: Test run command - with verbose flag
Given I have a valid configuration file
And I have a prompt for the agent
When I run the run command with verbose flag
Then the command should execute successfully with verbose output
And the result should be output
Scenario: Test run command - with unsafe flag
Given I have a valid configuration file
And I have a prompt for the agent
When I run the run command with unsafe flag
Then the command should execute successfully with unsafe mode
And the result should be output
Scenario: Test run command - UnsafeConfigurationError
Given I have a configuration file that triggers unsafe error
And I have a prompt for the agent
When I run the run command and get unsafe error
Then the command should exit with code 1
And an unsafe error message should be displayed
Scenario: Test run command - CleverAgentsException
Given I have a configuration file that triggers agent error
And I have a prompt for the agent
When I run the run command and get agent error
Then the command should exit with code 1
And an agent error message should be displayed
Scenario: Test run command - FileNotFoundError
Given I have a nonexistent configuration file
And I have a prompt for the agent
When I run the run command with missing config
Then the command should exit with code 2
And a file not found error message should be displayed
Scenario: Test run command - generic Exception
Given I have a configuration file that triggers generic error
And I have a prompt for the agent
When I run the run command and get generic error
Then the command should exit with code 1
And a generic error message should be displayed
Scenario: Test run command - early validation called
Given I have multiple configuration files
And I have a prompt for the agent
When I run the run command with multiple configs
Then early validation should be called
And the command should execute successfully
# Interactive command tests
Scenario: Test interactive command - successful execution
Given I have a valid configuration file for interactive
When I run the interactive command
Then the interactive session should start successfully
Scenario: Test interactive command - with history file
Given I have a valid configuration file for interactive
And I have a history file path
When I run the interactive command with history
Then the interactive session should start with history
And the history file should be used
Scenario: Test interactive command - with verbose flag
Given I have a valid configuration file for interactive
When I run the interactive command with verbose flag
Then the interactive session should start with verbose output
Scenario: Test interactive command - with unsafe flag
Given I have a valid configuration file for interactive
When I run the interactive command with unsafe flag
Then the interactive session should start with unsafe mode
Scenario: Test interactive command - UnsafeConfigurationError
Given I have a configuration file that triggers unsafe error for interactive
When I run the interactive command and get unsafe error
Then the command should exit with code 1
And an unsafe error message should be displayed for interactive
Scenario: Test interactive command - CleverAgentsException
Given I have a configuration file that triggers agent error for interactive
When I run the interactive command and get agent error
Then the command should exit with code 1
And an agent error message should be displayed for interactive
# Generate examples command tests
Scenario: Test generate_examples command - default output directory
When I run the generate_examples command
Then example files should be created in the default directory
And basic_reactive.yaml should be created
And advanced_reactive.yaml should be created
And collaboration_reactive.yaml should be created
And success messages should be displayed
Scenario: Test generate_examples command - custom output directory
Given I have a custom output directory
When I run the generate_examples command with custom output
Then example files should be created in the custom directory
And basic_reactive.yaml should be created in custom directory
And advanced_reactive.yaml should be created in custom directory
And collaboration_reactive.yaml should be created in custom directory
And success messages should be displayed for custom directory
Scenario: Test generate_examples command - directory creation
Given I have a nonexistent output directory
When I run the generate_examples command with nonexistent directory
Then the output directory should be created
And example files should be created in the new directory
# Visualize command tests
Scenario: Test visualize command - mermaid format to stdout
Given I have a valid configuration file for visualization
When I run the visualize command with mermaid format
Then a mermaid diagram should be generated
And the diagram should be output to stdout
Scenario: Test visualize command - mermaid format to file
Given I have a valid configuration file for visualization
And I have an output file for diagram
When I run the visualize command with mermaid format and output file
Then a mermaid diagram should be generated
And the diagram should be written to the output file
And a success message should be displayed for diagram
Scenario: Test visualize command - dot format
Given I have a valid configuration file for visualization
When I run the visualize command with dot format
Then a dot diagram should be generated
And the diagram should be output to stdout
Scenario: Test visualize command - ascii format
Given I have a valid configuration file for visualization
When I run the visualize command with ascii format
Then an ascii diagram should be generated
And the diagram should be output to stdout
Scenario: Test visualize command - no configuration loaded
Given I have a configuration file with no config loaded
When I run the visualize command with no config
Then the command should exit with code 1
And a no configuration error should be displayed
Scenario: Test visualize command - CleverAgentsException
Given I have a configuration file that triggers visualization error
When I run the visualize command and get error
Then the command should exit with code 1
And a visualization error message should be displayed
# Mermaid diagram generation tests
Scenario: Test _generate_mermaid_diagram - basic structure
Given I have a config with agents and routes
When I generate a mermaid diagram
Then the diagram should contain graph TD header
And the diagram should contain agent nodes
And the diagram should contain route nodes
Scenario: Test _generate_mermaid_diagram - stream routes with agents
Given I have a config with stream routes and connected agents
When I generate a mermaid diagram for streams
Then the diagram should contain stream nodes with proper shapes
And the diagram should contain agent to stream connections
Scenario: Test _generate_mermaid_diagram - graph routes
Given I have a config with graph routes
When I generate a mermaid diagram for graphs
Then the diagram should contain graph nodes with proper shapes
Scenario: Test _generate_mermaid_diagram - merges
Given I have a config with merge configurations
When I generate a mermaid diagram with merges
Then the diagram should contain merge connections
Scenario: Test _generate_mermaid_diagram - splits with dict targets
Given I have a config with split configurations using dict targets
When I generate a mermaid diagram with dict splits
Then the diagram should contain split connections from dict targets
Scenario: Test _generate_mermaid_diagram - splits with string targets
Given I have a config with split configurations using string targets
When I generate a mermaid diagram with string splits
Then the diagram should contain split connections from string targets
Scenario: Test _generate_mermaid_diagram - splits with list targets
Given I have a config with split configurations using list targets
When I generate a mermaid diagram with list splits
Then the diagram should contain split connections from list targets
Scenario: Test _generate_mermaid_diagram - splits with other targets
Given I have a config with split configurations using other targets
When I generate a mermaid diagram with other splits
Then the diagram should handle other target types gracefully
# DOT diagram generation tests
Scenario: Test _generate_dot_diagram - basic structure
Given I have a config with agents and routes for dot
When I generate a dot diagram
Then the diagram should contain digraph header
And the diagram should contain agent nodes with box shapes
And the diagram should contain route nodes
Scenario: Test _generate_dot_diagram - stream routes with agents
Given I have a config with stream routes and agents for dot
When I generate a dot diagram for streams
Then the diagram should contain stream nodes with proper shapes
And the diagram should contain agent to stream connections for dot
Scenario: Test _generate_dot_diagram - graph routes
Given I have a config with graph routes for dot
When I generate a dot diagram for graphs
Then the diagram should contain graph nodes with hexagon shapes
Scenario: Test _generate_dot_diagram - merges and splits
Given I have a config with merges and splits for dot
When I generate a dot diagram with connections
Then the diagram should contain merge and split connections
And the diagram should end with closing brace
Scenario: Test _generate_dot_diagram - split target type handling
Given I have a config with various split target types for dot
When I generate a dot diagram with various splits
Then the diagram should handle all target types correctly for dot
# ASCII diagram generation tests
Scenario: Test _generate_ascii_diagram - basic structure
Given I have a config with agents and routes for ascii
When I generate an ascii diagram
Then the diagram should contain header and separators
And the diagram should list agents with types
And the diagram should list routes with types
Scenario: Test _generate_ascii_diagram - stream routes with details
Given I have a config with stream routes with agents and operators
When I generate an ascii diagram for detailed streams
Then the diagram should show stream details
And the diagram should show connected agents
And the diagram should show operator counts
Scenario: Test _generate_ascii_diagram - graph routes with details
Given I have a config with graph routes with nodes and edges
When I generate an ascii diagram for detailed graphs
Then the diagram should show graph details
And the diagram should show node counts
And the diagram should show edge counts
Scenario: Test _generate_ascii_diagram - merges section
Given I have a config with merges for ascii
When I generate an ascii diagram with merges
Then the diagram should contain merges section
And the diagram should show merge connections
Scenario: Test _generate_ascii_diagram - splits section
Given I have a config with splits for ascii
When I generate an ascii diagram with splits
Then the diagram should contain splits section
And the diagram should show split connections
Scenario: Test _generate_ascii_diagram - split target type handling
Given I have a config with various split types for ascii
When I generate an ascii diagram with various split types
Then the diagram should handle all split target types for ascii
# Configuration validation tests
Scenario: Test _validate_config_files - no config files provided
Given I have no configuration files
When I validate the configuration files
Then a CleverAgentsException should be raised about no files
Scenario: Test _validate_config_files - nonexistent file
Given I have a nonexistent configuration file for validation
When I validate the nonexistent configuration file
Then a FileNotFoundError should be raised
Scenario: Test _validate_config_files - empty file
Given I have an empty configuration file
When I validate the empty configuration file
Then a CleverAgentsException should be raised about empty file
Scenario: Test _validate_config_files - dev null file
Given I have a dev null configuration file
When I validate the dev null configuration file
Then a CleverAgentsException should be raised about invalid file
Scenario: Test _validate_config_files - null named file
Given I have a null named configuration file
When I validate the null named configuration file
Then a CleverAgentsException should be raised about null file
Scenario: Test _validate_config_files - NUL named file
Given I have a NUL named configuration file
When I validate the NUL named configuration file
Then a CleverAgentsException should be raised about NUL file
Scenario: Test _validate_config_files - whitespace only file
Given I have a whitespace only configuration file
When I validate the whitespace only configuration file
Then a CleverAgentsException should be raised about whitespace file
Scenario: Test _validate_config_files - unreadable file
Given I have an unreadable configuration file
When I validate the unreadable configuration file
Then a CleverAgentsException should be raised about unreadable file
Scenario: Test _validate_config_files - valid files
Given I have valid configuration files for validation
When I validate the valid configuration files
Then the validation should pass successfully
# Main entry point test
Scenario: Test main entry point
When the CLI module is run as main
Then the main function should be called