forked from cleveragents/cleveragents-core
156 lines
7.2 KiB
Gherkin
156 lines
7.2 KiB
Gherkin
Feature: YAML Preprocessor Comprehensive Coverage
|
|
As a developer
|
|
I want to thoroughly test the YAMLTemplateProcessor and TemplateAwareConfigParser classes
|
|
So that we achieve 90%+ code coverage for yaml_preprocessor.py
|
|
|
|
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 |