Files
cleveragents-core/tests/features/template_store_coverage.feature
T

132 lines
5.4 KiB
Gherkin

Feature: Template Store Coverage
As a developer
I want to test all Template Store functionality
So that we achieve 90%+ code coverage for template_store.py
Background:
Given a clean template store test environment
Scenario: Test TemplateStore initialization
When I create a new TemplateStore
Then the template store should be initialized with empty collections
And the template store should have three template types
Scenario: Test add_template with string definition
Given I have a TemplateStore
When I add a string template definition
Then the template should be stored as raw YAML
And metadata should be extracted successfully
Scenario: Test add_template with dict definition
Given I have a TemplateStore
When I add a dict template definition
Then the template should be converted to YAML string
And metadata should be extracted from dict
Scenario: Test add_template with invalid YAML string
Given I have a TemplateStore
When I add an invalid YAML string template
Then the template should be stored anyway
And a warning should be logged for metadata extraction failure
Scenario: Test get_template with existing template
Given I have a TemplateStore with stored templates
When I get an existing template
Then the raw template string should be returned
Scenario: Test get_template with non-existing template
Given I have a TemplateStore
When I get a non-existing template
Then None should be returned for template
Scenario: Test get_metadata with existing template
Given I have a TemplateStore with stored templates
When I get metadata for an existing template
Then the template metadata should be returned
Scenario: Test get_metadata with non-existing template
Given I have a TemplateStore
When I get metadata for a non-existing template
Then None should be returned for metadata
Scenario: Test instantiate_template with existing template
Given I have a TemplateStore with a templated definition
When I instantiate the template store template with parameters
Then the template should be processed with parameters
And utility functions should be available in context
Scenario: Test instantiate_template with non-existing template
Given I have a TemplateStore
When I try to instantiate a non-existing template
Then a ValueError should be raised with template not found message
Scenario: Test TemplateDefinition with string input
When I create a TemplateDefinition with a string
Then the raw YAML should be stored
And the definition should be parsed correctly
And template syntax should be detected
Scenario: Test TemplateDefinition with dict input
When I create a TemplateDefinition with a dict
Then the dict should be converted to YAML
And the parsed definition should match input
And template syntax should be detected in YAML
Scenario: Test TemplateDefinition with invalid YAML string
When I create a TemplateDefinition with invalid YAML
Then the raw YAML should be stored
And the parsed definition should be empty dict
And template syntax detection should still work
Scenario: Test TemplateDefinition template syntax detection
When I create a TemplateDefinition with Jinja2 syntax
Then template syntax should be automatically detected
And contains_templates should be True
Scenario: Test TemplateDefinition without template syntax
When I create a TemplateDefinition without Jinja2 syntax
Then template syntax should not be detected
And contains_templates should be False
Scenario: Test TemplateDefinition with explicit contains_templates flag
When I create a TemplateDefinition with explicit template flag
Then the explicit flag should be used
And automatic detection should be skipped
Scenario: Test TemplateDefinition get_parameters method
Given I have a TemplateDefinition with parameters
When I call get_parameters
Then the parameters should be returned correctly
Scenario: Test TemplateDefinition get_type method
Given I have a TemplateDefinition with type
When I call get_type
Then the type should be returned correctly
Scenario: Test TemplateDefinition get_type method with no type
Given I have a TemplateDefinition without type
When I call get_type
Then the default type "unknown" should be returned
Scenario: Test TemplateDefinition instantiate without templates
Given I have a TemplateDefinition without Jinja2 templates
When I call instantiate
Then the parsed definition should be returned unchanged
Scenario: Test TemplateDefinition instantiate with templates
Given I have a TemplateDefinition with Jinja2 templates
When I call instantiate with parameters
Then the template should be processed
And utility functions should be available in the context
Scenario: Test TemplateStore add_template with dict type conversions
Given I have a TemplateStore
When I add multiple template types with dict definitions
Then all template types should be converted to YAML correctly
And all metadata should be extracted properly
Scenario: Test comprehensive template store functionality
Given I have a TemplateStore
When I perform comprehensive template store operations
Then all TemplateStore code paths should be exercised
And all TemplateDefinition code paths should be exercised