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.
220 lines
10 KiB
Gherkin
220 lines
10 KiB
Gherkin
Feature: Enhanced Template Registry Registration and Instantiation
|
|
As a developer
|
|
I want the enhanced registry to register templates from strings, files, and dicts, and instantiate them from cache or store
|
|
So that templates with Jinja2 syntax are preserved for deferred rendering while simple templates are cached in memory
|
|
|
|
Background:
|
|
Given EReg: I have a clean test environment for enhanced registry
|
|
|
|
Scenario: Test EnhancedTemplateRegistry initialization
|
|
Given EReg: I create an enhanced template registry
|
|
Then EReg: the registry should be initialized correctly
|
|
And EReg: the registry should have empty template caches
|
|
And EReg: the registry should have a template store
|
|
And EReg: the registry should have a YAML processor
|
|
|
|
Scenario: Test register_template_string with different template types
|
|
Given EReg: I create an enhanced template registry
|
|
And EReg: I have a template YAML string for agent type
|
|
When EReg: I register the template string with agent type
|
|
Then EReg: the template should be stored in the store
|
|
And EReg: the template should be accessible by type and name
|
|
|
|
Scenario: Test register_template_string with graph type
|
|
Given EReg: I create an enhanced template registry
|
|
And EReg: I have a template YAML string for graph type
|
|
When EReg: I register the template string with graph type
|
|
Then EReg: the template should be stored in the store
|
|
And EReg: the template should be accessible by type and name
|
|
|
|
Scenario: Test register_template_string with stream type
|
|
Given EReg: I create an enhanced template registry
|
|
And EReg: I have a template YAML string for stream type
|
|
When EReg: I register the template string with stream type
|
|
Then EReg: the template should be stored in the store
|
|
And EReg: the template should be accessible by type and name
|
|
|
|
Scenario: Test register_template_file functionality
|
|
Given EReg: I create an enhanced template registry
|
|
And EReg: I have a template file on disk
|
|
When EReg: I register the template from file
|
|
Then EReg: the template should be loaded from file and stored
|
|
And EReg: the file content should be registered as template string
|
|
|
|
Scenario: Test register_template_dict with Jinja2 syntax
|
|
Given EReg: I create an enhanced template registry
|
|
And EReg: I have a template dictionary with Jinja2 syntax
|
|
When EReg: I register the template dictionary
|
|
Then EReg: the template should be stored as YAML string
|
|
And EReg: the Jinja2 syntax should be preserved
|
|
|
|
Scenario: Test register_template_dict without Jinja2 syntax
|
|
Given EReg: I create an enhanced template registry
|
|
And EReg: I have a simple template dictionary without Jinja2
|
|
When EReg: I register the simple template dictionary
|
|
Then EReg: the template should be registered as simple template
|
|
And EReg: the template should be cached in memory
|
|
|
|
Scenario: Test _register_simple_template for agent type
|
|
Given EReg: I create an enhanced template registry
|
|
And EReg: I have a simple agent template definition
|
|
When EReg: I register the simple agent template
|
|
Then EReg: an AgentTemplate instance should be created
|
|
And EReg: the template should be cached correctly
|
|
|
|
Scenario: Test _register_simple_template for composite agent type
|
|
Given EReg: I create an enhanced template registry
|
|
And EReg: I have a composite agent template definition for enhanced registry
|
|
When EReg: I register the composite agent template for enhanced registry
|
|
Then EReg: a CompositeAgentTemplate instance should be created
|
|
And EReg: the template should be cached correctly
|
|
|
|
Scenario: Test _register_simple_template for graph type
|
|
Given EReg: I create an enhanced template registry
|
|
And EReg: I have a simple graph template definition for enhanced registry
|
|
When EReg: I register the simple graph template in enhanced registry
|
|
Then EReg: a GraphTemplate instance should be created
|
|
And EReg: the template should be cached correctly
|
|
|
|
Scenario: Test _register_simple_template for stream type
|
|
Given EReg: I create an enhanced template registry
|
|
And EReg: I have a simple stream template definition for enhanced registry
|
|
When EReg: I register the simple stream template in enhanced registry
|
|
Then EReg: a StreamTemplate instance should be created
|
|
And EReg: the template should be cached correctly
|
|
|
|
Scenario: Test _register_simple_template with unknown type
|
|
Given EReg: I create an enhanced template registry
|
|
And EReg: I have a template definition with unknown type
|
|
When EReg: I try to register the unknown template type
|
|
Then EReg: a ValueError should be raised for unknown type
|
|
|
|
Scenario: Test get_template from cache
|
|
Given EReg: I create an enhanced template registry
|
|
And EReg: I have a cached template
|
|
When EReg: I get the template by type and name
|
|
Then EReg: the cached template should be returned
|
|
|
|
Scenario: Test get_template from store (complex template)
|
|
Given EReg: I create an enhanced template registry
|
|
And EReg: I have a complex template in store only
|
|
When EReg: I try to get the complex template
|
|
Then EReg: a ValueError should be raised about complex template
|
|
|
|
Scenario: Test get_template not found
|
|
Given EReg: I create an enhanced template registry
|
|
When EReg: I try to get a non-existent template
|
|
Then EReg: a ValueError should be raised for template not found
|
|
|
|
Scenario: Test instantiate from cache
|
|
Given EReg: I create an enhanced template registry
|
|
And EReg: I have a cached template with parameters
|
|
When EReg: I instantiate the cached template
|
|
Then EReg: the template instantiate method should be called
|
|
And EReg: the configuration should be returned
|
|
|
|
Scenario: Test instantiate from store
|
|
Given EReg: I create an enhanced template registry
|
|
And EReg: I have a template in store only
|
|
And EReg: I have template parameters
|
|
When EReg: I instantiate the template from store
|
|
Then EReg: the store instantiate method should be called
|
|
And EReg: the instantiated configuration should be returned
|
|
|
|
Scenario: Test instantiate with context processing
|
|
Given EReg: I create an enhanced template registry
|
|
And EReg: I have a template in store with context
|
|
And EReg: I have template parameters and context
|
|
When EReg: I instantiate the template with context
|
|
Then EReg: the context should be processed
|
|
And EReg: the instantiated configuration should be returned
|
|
|
|
Scenario: Test instantiate template not found
|
|
Given EReg: I create an enhanced template registry
|
|
When EReg: I try to instantiate a non-existent template
|
|
Then EReg: a ValueError should be raised for instantiate not found
|
|
|
|
Scenario: Test register_all_templates with agents
|
|
Given EReg: I create an enhanced template registry
|
|
And EReg: I have a templates configuration with agents
|
|
When EReg: I register all templates from configuration
|
|
Then EReg: all agent templates should be registered
|
|
And EReg: the templates should be accessible
|
|
|
|
Scenario: Test register_all_templates with graphs
|
|
Given EReg: I create an enhanced template registry
|
|
And EReg: I have a templates configuration with graphs
|
|
When EReg: I register all templates from configuration
|
|
Then EReg: all graph templates should be registered
|
|
And EReg: the templates should be accessible
|
|
|
|
Scenario: Test register_all_templates with streams
|
|
Given EReg: I create an enhanced template registry
|
|
And EReg: I have a templates configuration with streams
|
|
When EReg: I register all templates from configuration
|
|
Then EReg: all stream templates should be registered
|
|
And EReg: the templates should be accessible
|
|
|
|
Scenario: Test register_all_templates with unknown type
|
|
Given EReg: I create an enhanced template registry
|
|
And EReg: I have a templates configuration with unknown type
|
|
When EReg: I register all templates from configuration
|
|
Then EReg: the unknown type should be logged as warning
|
|
And EReg: known types should still be processed
|
|
|
|
Scenario: Test has_template from cache
|
|
Given EReg: I create an enhanced template registry
|
|
And EReg: I have a cached template
|
|
When EReg: I check if the template exists in enhanced registry
|
|
Then EReg: the result should be true
|
|
|
|
Scenario: Test has_template from store
|
|
Given EReg: I create an enhanced template registry
|
|
And EReg: I have a template in store only
|
|
When EReg: I check if the template exists in enhanced registry
|
|
Then EReg: the result should be true
|
|
|
|
Scenario: Test has_template not found
|
|
Given EReg: I create an enhanced template registry
|
|
When EReg: I check if a non-existent template exists in enhanced registry
|
|
Then EReg: the result should be false
|
|
|
|
Scenario: Test get_template_metadata from cache
|
|
Given EReg: I create an enhanced template registry
|
|
And EReg: I have a cached template with metadata
|
|
When EReg: I get the template metadata
|
|
Then EReg: the metadata should include type and parameters
|
|
And EReg: the parameters should be properly formatted
|
|
|
|
Scenario: Test get_template_metadata from store
|
|
Given EReg: I create an enhanced template registry
|
|
And EReg: I have a template in store only with metadata
|
|
When EReg: I get the template metadata
|
|
Then EReg: the store metadata should be returned
|
|
|
|
Scenario: Test get_template_metadata not found
|
|
Given EReg: I create an enhanced template registry
|
|
When EReg: I try to get metadata for non-existent template
|
|
Then EReg: a ValueError should be raised for metadata not found
|
|
|
|
Scenario: Test list_templates for specific type
|
|
Given EReg: I create an enhanced template registry
|
|
And EReg: I have templates of different types
|
|
When EReg: I list templates for agent type
|
|
Then EReg: only agent template names should be returned
|
|
And EReg: duplicates should be removed
|
|
|
|
Scenario: Test list_templates for all types
|
|
Given EReg: I create an enhanced template registry
|
|
And EReg: I have templates of different types
|
|
When EReg: I list all templates
|
|
Then EReg: all template types should be included
|
|
And EReg: each type should have its template names
|
|
And EReg: duplicates should be removed from each type
|
|
|
|
Scenario: Agent from enhanced registry template
|
|
Given a config with enhanced registry agent template
|
|
When loading the configuration for enhanced registry test
|
|
Then agent is created from enhanced registry template
|
|
And enhanced registry is used for application
|