9753b31c7e
CI / quality (push) Successful in 36s
CI / lint (push) Successful in 38s
CI / typecheck (push) Successful in 49s
CI / security (push) Successful in 51s
CI / integration_tests (push) Successful in 55s
CI / unit_tests (push) Successful in 3m35s
CI / build (push) Successful in 33s
CI / coverage (push) Successful in 3m36s
CI / status-check (push) Successful in 3s
Add 13 BDD scenarios covering previously uncovered code paths: - SAFE_BUILTINS validation (sandbox.py: 0% → 100%) - ConfigurationError re-raise path (config.py: 99.3% → 100%) - CLI hello/main functions (cli.py: 72.7% → 90.9%) - GraphState message truncation (state.py: 98.7% → 100%) - ProgressBarManager update/context rendering (progress.py: 0% → 87.7%) - MessageRouter regex/exact/contains routing (message_router.py: 0% → 59.4%) - RoutingAdapter parse_routing_command (routing_adapter.py) - DynamicRouterNode pattern-based routing (dynamic_router.py) - EnhancedTemplateRegistry unknown template type (enhanced_registry.py: 99.2%) - CompositeAgent null-graph error path (composite.py: 97.8% → 98.6%) Cover routing_adapter.py (17% → 100%): all GOTO/ROUTE patterns, create_routing_node, create_conditional_router, dynamic config conversion. Cover dynamic_router.py (21% → 87%): execute with empty/dict/string messages, extract_message with colon parsing, config creation, graph extension with edge generation. Cover message_router.py (59% → 78%): regex, exact, contains, prefix, suffix match types, invalid regex handling, non-string message, set_state. Exercise Node._prepare_conversation_history with invalid configs, _runtime error paths, _execute_message_router with rules, _execute_agent with current_message and metadata propagation, _execute_function with dynamic_router, and _execute_conditional with content_contains/content_not_contains/content_starts_with and custom condition types. Improves nodes.py from 71.3% to 72.5%. Exercise PureGraphConfig, PureLangGraph init with dict/config, RxPyLangGraphBridge registration/connection/lookup, ReactiveStreamRouter operator creation and condition functions, ReactiveConfigParser config/route/graph parsing, ToolAgent tool execution with JSON, space-separated, single, file_read, progress_bar invocations, and ReactiveCleverAgentsApp init/dispose/visualization.
157 lines
7.3 KiB
Gherkin
157 lines
7.3 KiB
Gherkin
Feature: YAML Template Processor and TemplateAwareConfigParser
|
|
As a developer
|
|
I want the YAMLTemplateProcessor to process files and strings with templates, extract variables, and TemplateAwareConfigParser to parse with custom context
|
|
So that templates in YAML configurations are rendered with built-in utility functions and proper error handling
|
|
|
|
Background:
|
|
Given I have a clean yaml processor test environment
|
|
|
|
# YAMLTemplateProcessor Tests
|
|
|
|
Scenario: Initialize YAMLTemplateProcessor correctly
|
|
When I create a yaml processor instance
|
|
Then the yaml processor jinja environment should be configured properly
|
|
And the yaml processor should be properly initialized
|
|
|
|
Scenario: Process file without templates
|
|
Given I have a yaml file without jinja templates for yaml processor
|
|
When I process the yaml file using process_file
|
|
Then it should return the parsed yaml content correctly
|
|
|
|
Scenario: Process file with templates and context
|
|
Given I have a yaml file with jinja templates for yaml processor
|
|
And I have yaml processor template rendering context
|
|
When I process the yaml file with context using process_file
|
|
Then it should render yaml templates and return parsed yaml
|
|
|
|
Scenario: Process string without templates
|
|
Given I have a yaml string without jinja templates for yaml processor
|
|
When I process the yaml string using process_string
|
|
Then it should return the parsed yaml content correctly
|
|
|
|
Scenario: Process string with templates and context
|
|
Given I have a yaml string with jinja templates for yaml processor
|
|
And I have yaml processor template rendering context
|
|
When I process the yaml string with context using process_string
|
|
Then it should render yaml templates and return parsed yaml
|
|
|
|
Scenario: Handle YAML parsing errors in process_string
|
|
Given I have a yaml string causing parsing errors
|
|
When I process the yaml string with parsing errors
|
|
Then it should log yaml error and raise YAMLError
|
|
|
|
Scenario: Handle template rendering errors in process_string
|
|
Given I have a yaml string with invalid jinja templates for yaml processor
|
|
When I process the yaml string with invalid templates
|
|
Then it should log template error and raise template exception
|
|
|
|
Scenario: Process template blocks with loops
|
|
Given I have a yaml string with for loop templates for yaml processor
|
|
And I have yaml processor context with loop variables
|
|
When I process the yaml string with loop context
|
|
Then it should render the yaml loop correctly
|
|
|
|
Scenario: Process template blocks with conditionals
|
|
Given I have a yaml string with if conditional templates for yaml processor
|
|
And I have yaml processor context with conditional variables
|
|
When I process the yaml string with conditional context
|
|
Then it should render the yaml conditionals correctly
|
|
|
|
Scenario: Process inline templates with filters
|
|
Given I have a yaml string with jinja filters
|
|
And I have yaml processor context for filter templates
|
|
When I process the yaml string with filters
|
|
Then it should apply yaml filters correctly
|
|
|
|
Scenario: Extract variables from template content
|
|
Given I have a yaml string with template variables
|
|
When I extract variables from the yaml template
|
|
Then it should return all yaml template variables used
|
|
|
|
Scenario: Extract variables from complex templates
|
|
Given I have a yaml string with complex template structures
|
|
When I extract variables from yaml complex templates
|
|
Then it should return all yaml variables including nested ones
|
|
|
|
Scenario: Handle empty template content in extract_variables
|
|
Given I have empty yaml content for variable extraction
|
|
When I extract variables from empty yaml content
|
|
Then it should return an empty variable set
|
|
|
|
# TemplateAwareConfigParser Tests
|
|
|
|
Scenario: Initialize TemplateAwareConfigParser correctly
|
|
When I create a template aware config parser instance
|
|
Then the config parser should be initialized with yaml template processor
|
|
And the config parser logger should be configured
|
|
|
|
Scenario: Parse template file without context
|
|
Given I have a yaml file with templates for config parser
|
|
When I parse the template file without context
|
|
Then it should add builtin functions to context and parse correctly
|
|
|
|
Scenario: Parse template file with custom context
|
|
Given I have a yaml file with templates for config parser
|
|
And I have custom template context for config parser
|
|
When I parse the template file with custom context
|
|
Then it should merge contexts and parse yaml correctly
|
|
|
|
Scenario: Parse template file with file not found error
|
|
Given I have an invalid file path for config parser
|
|
When I try to parse the invalid file with config parser
|
|
Then it should log error and raise FileNotFoundError for config parser
|
|
|
|
Scenario: Parse template file with processing error
|
|
Given I have a yaml file causing processing errors
|
|
When I try to parse the problematic file with config parser
|
|
Then it should log error and reraise the exception for config parser
|
|
|
|
Scenario: Parse template string without context
|
|
Given I have a yaml string with templates for config parser
|
|
When I parse the template string without context
|
|
Then it should add builtin functions and parse string correctly
|
|
|
|
Scenario: Parse template string with custom context
|
|
Given I have a yaml string with templates for config parser
|
|
And I have custom template context for config parser
|
|
When I parse the template string with custom context
|
|
Then it should merge contexts and parse yaml correctly
|
|
|
|
Scenario: Parse template string with processing error
|
|
Given I have a yaml string causing processing errors
|
|
When I try to parse the problematic string with config parser
|
|
Then it should log template error and raise template exception
|
|
|
|
Scenario: Built-in functions are available in template context
|
|
Given I have a yaml string using builtin functions
|
|
When I parse the string with builtin functions
|
|
Then it should successfully use range len str int float bool list dict functions
|
|
|
|
Scenario: Template context merging shows builtin functions override custom values
|
|
Given I have custom template context with builtin function names
|
|
When I parse a template with context merging
|
|
Then custom values should override builtin functions
|
|
|
|
Scenario: Cover YAML parsing error path in process_string
|
|
Given I have a clean yaml processor test environment
|
|
Given I have a yaml string that will cause YAML parsing errors
|
|
When I process the yaml string that causes YAML errors
|
|
Then it should raise YAMLError and log the error
|
|
|
|
Scenario: Cover template processing error path
|
|
Given I have a clean yaml processor test environment
|
|
Given I have a yaml string with template syntax errors
|
|
When I process the yaml string with template errors
|
|
Then it should raise template exception and log the error
|
|
|
|
Scenario: Direct test of process_file method coverage
|
|
Given I have a clean yaml processor test environment
|
|
Given I have a simple yaml file for direct testing
|
|
When I call process_file method directly
|
|
Then it should process the file and return yaml data
|
|
|
|
Scenario: Force coverage of unused private methods
|
|
Given I have a clean yaml processor test environment
|
|
When I directly call the private template processing methods
|
|
Then the private methods should be executed
|