forked from cleveragents/cleveragents-core
166 lines
7.2 KiB
Gherkin
166 lines
7.2 KiB
Gherkin
Feature: Templates Base Module Coverage
|
|
As a developer
|
|
I want to test all functionality in the templates base module
|
|
So that we achieve 90%+ code coverage for the base.py file
|
|
|
|
Background:
|
|
Given I have a clean test environment for templates
|
|
|
|
Scenario: Test TemplateType enum functionality
|
|
When I access all TemplateType enum values
|
|
Then all template types should be available
|
|
And enum values should have correct string representations
|
|
|
|
Scenario: Test TemplateParameter creation and validation - string type
|
|
Given I have a string template parameter with default value
|
|
When I validate different string values
|
|
Then string validation should work correctly
|
|
And default values should be used when None
|
|
|
|
Scenario: Test TemplateParameter validation - int type
|
|
Given I have an integer template parameter
|
|
When I validate integer values including conversions
|
|
Then integer validation should work correctly
|
|
And invalid integers should raise errors
|
|
|
|
Scenario: Test TemplateParameter validation - float type
|
|
Given I have a float template parameter
|
|
When I validate float values including conversions
|
|
Then float validation should work correctly
|
|
|
|
Scenario: Test TemplateParameter validation - boolean type
|
|
Given I have a boolean template parameter
|
|
When I validate boolean values including string conversions
|
|
Then boolean validation should work correctly
|
|
And string boolean values should convert properly
|
|
|
|
Scenario: Test TemplateParameter validation - enum type
|
|
Given I have an enum template parameter with allowed values
|
|
When I validate enum values
|
|
Then valid enum values should pass
|
|
And invalid enum values should raise errors
|
|
|
|
Scenario: Test TemplateParameter validation - list type
|
|
Given I have a list template parameter
|
|
When I validate list values including single value conversion
|
|
Then list validation should work correctly
|
|
And single values should convert to lists
|
|
|
|
Scenario: Test TemplateParameter validation - dict and reference types
|
|
Given I have parameters of different reference types
|
|
When I validate dict, agent_ref, and component_ref values
|
|
Then reference type validation should work correctly
|
|
|
|
Scenario: Test TemplateParameter required parameter validation
|
|
Given I have a required template parameter
|
|
When I validate with None value
|
|
Then a ValueError should be raised for missing required parameter
|
|
|
|
Scenario: Test ComponentReference creation and basic functionality
|
|
Given I have component references of different types
|
|
When I create ComponentReference instances
|
|
Then component references should be created correctly
|
|
And reference properties should be accessible
|
|
|
|
Scenario: Test InstantiationContext creation and component management
|
|
Given I have an InstantiationContext
|
|
When I add components of different types
|
|
Then components should be stored correctly
|
|
And component retrieval should work
|
|
|
|
Scenario: Test InstantiationContext with parent context
|
|
Given I have a parent InstantiationContext with components
|
|
And I have a child context
|
|
When I try to resolve references in child context
|
|
Then child context should check parent for references
|
|
|
|
Scenario: Test InstantiationContext reference resolution
|
|
Given I have an InstantiationContext with components
|
|
When I resolve component references
|
|
Then existing references should be resolved correctly
|
|
And missing references should return None
|
|
|
|
Scenario: Test InstantiationContext pending reference handling
|
|
Given I have an InstantiationContext
|
|
When I resolve references that don't exist yet
|
|
Then references should be added to pending list
|
|
And resolve_pending should handle unresolved references
|
|
|
|
Scenario: Test InstantiationContext get_all_components
|
|
Given I have an InstantiationContext with various components
|
|
When I get all components
|
|
Then a deep copy of all components should be returned
|
|
|
|
Scenario: Test BaseTemplate parameter parsing - dict format
|
|
Given I have a template definition with dict format parameters
|
|
When I create a BaseTemplate instance
|
|
Then parameters should be parsed correctly from dict format
|
|
|
|
Scenario: Test BaseTemplate parameter parsing - list format
|
|
Given I have a template definition with list format parameters
|
|
When I create a BaseTemplate instance
|
|
Then parameters should be parsed correctly from list format
|
|
|
|
Scenario: Test BaseTemplate parameter parsing - mixed formats
|
|
Given I have a template definition with mixed parameter formats
|
|
When I create a BaseTemplate instance
|
|
Then all parameter formats should be parsed correctly
|
|
|
|
Scenario: Test BaseTemplate validate_params functionality
|
|
Given I have a BaseTemplate with various parameter types
|
|
When I validate parameters with different values
|
|
Then parameter validation should work correctly
|
|
And extra parameters should be included
|
|
|
|
Scenario: Test BaseTemplate _apply_template_vars - string templates
|
|
Given I have a BaseTemplate instance
|
|
When I apply template variables to string templates
|
|
Then Jinja2 templates should be rendered correctly
|
|
And boolean strings should convert to boolean values
|
|
|
|
Scenario: Test BaseTemplate _apply_template_vars - JSON parsing
|
|
Given I have a BaseTemplate instance
|
|
When I apply template variables that result in JSON-like strings
|
|
Then JSON structures should be parsed correctly
|
|
And malformed JSON should fall back to string
|
|
|
|
Scenario: Test BaseTemplate _apply_template_vars - number parsing
|
|
Given I have a BaseTemplate instance
|
|
When I apply template variables that result in numbers
|
|
Then integers and floats should be parsed correctly
|
|
|
|
Scenario: Test BaseTemplate _apply_template_vars - dict processing
|
|
Given I have a BaseTemplate instance
|
|
When I apply template variables to dictionary structures
|
|
Then dictionary keys and values should be processed recursively
|
|
And None values should be filtered out
|
|
|
|
Scenario: Test BaseTemplate _apply_template_vars - conditional blocks
|
|
Given I have a BaseTemplate instance with conditional blocks
|
|
When I apply template variables to conditional structures
|
|
Then conditional blocks should be evaluated correctly
|
|
And false conditions should return None
|
|
|
|
Scenario: Test BaseTemplate _apply_template_vars - list processing
|
|
Given I have a BaseTemplate instance
|
|
When I apply template variables to list structures
|
|
Then list items should be processed recursively
|
|
And None values should be filtered from lists
|
|
|
|
Scenario: Test BaseTemplate _apply_template_vars - error handling
|
|
Given I have a BaseTemplate instance
|
|
When I apply template variables with invalid templates
|
|
Then template errors should be handled gracefully
|
|
And original values should be returned on error
|
|
|
|
Scenario: Test BaseTemplate _merge_params functionality
|
|
Given I have a BaseTemplate instance
|
|
When I merge parameter dictionaries with overrides
|
|
Then parameters should be merged correctly
|
|
And override values should be template-processed
|
|
|
|
Scenario: Test error conditions and edge cases
|
|
Given I have various edge case scenarios
|
|
When I test error conditions
|
|
Then appropriate errors should be raised
|
|
And edge cases should be handled correctly |