forked from HAL9000/cleveragents-core
155 lines
7.3 KiB
Gherkin
155 lines
7.3 KiB
Gherkin
Feature: Jinja YAML Preprocessor Coverage
|
|
As a developer
|
|
I want to thoroughly test the JinjaYAMLPreprocessor class
|
|
So that we achieve 90%+ code coverage
|
|
|
|
Background:
|
|
Given I have a JinjaYAMLPreprocessor instance
|
|
|
|
Scenario: Initialize JinjaYAMLPreprocessor with default settings
|
|
When I create a new JinjaYAMLPreprocessor instance
|
|
Then the Jinja2 environment should be configured correctly with trim_blocks and lstrip_blocks
|
|
|
|
Scenario: Load file without templates using load_file
|
|
Given I have a YAML file without Jinja templates for preprocessor
|
|
When I load the file using load_file
|
|
Then it should return parsed YAML without preprocessing
|
|
|
|
Scenario: Load file with templates using load_file and context
|
|
Given I have a YAML file with Jinja templates for preprocessor
|
|
And I have a rendering context for preprocessor
|
|
When I load the file with context using load_file
|
|
Then it should render and return parsed YAML via preprocessor
|
|
|
|
Scenario: Load string without templates using load_string
|
|
Given I have a YAML string without Jinja templates for preprocessor
|
|
When I load the string using load_string without context
|
|
Then it should return parsed YAML without preprocessing
|
|
|
|
Scenario: Load string with templates and context using load_string
|
|
Given I have a YAML string with Jinja templates for preprocessor
|
|
And I have a rendering context for preprocessor
|
|
When I load the string with context using load_string with preprocessor
|
|
Then it should render templates and return parsed YAML via preprocessor
|
|
|
|
Scenario: Load string with templates for deferred rendering
|
|
Given I have a YAML string with Jinja templates for preprocessor
|
|
When I load the string without context using load_string
|
|
Then it should preprocess for storage with template markers
|
|
|
|
Scenario: Render and parse with utilities in context
|
|
Given I have YAML content with Jinja templates for preprocessor
|
|
And I have a basic rendering context for preprocessor
|
|
When I render and parse using _render_and_parse
|
|
Then it should include built-in utilities in context and render correctly
|
|
|
|
Scenario: Preprocess for storage with template blocks
|
|
Given I have YAML with template blocks for preprocessing
|
|
When I preprocess for storage using _preprocess_for_storage
|
|
Then it should wrap template blocks in multiline strings with markers
|
|
|
|
Scenario: Preprocess for storage with inline templates
|
|
Given I have YAML with inline templates for preprocessing
|
|
When I preprocess inline templates for storage using _preprocess_for_storage
|
|
Then it should wrap inline templates with template markers
|
|
|
|
Scenario: Handle YAML parsing errors during preprocessing
|
|
Given I have YAML content that causes parsing errors during preprocessing
|
|
When I preprocess for storage and encounter YAML errors
|
|
Then it should log the error and raise appropriately
|
|
|
|
Scenario: Render deferred configuration
|
|
Given I have a preprocessed configuration with template markers
|
|
And I have a rendering context for preprocessor
|
|
When I render the deferred configuration
|
|
Then it should restore templates and render them correctly
|
|
|
|
Scenario: Handle non-deferred configuration in render_deferred
|
|
Given I have a regular configuration without template markers for preprocessor
|
|
When I try to render it as deferred
|
|
Then it should return the configuration unchanged for preprocessor
|
|
|
|
Scenario: Restore templates from inline template values
|
|
Given I have configuration with inline template markers
|
|
When I restore templates using _restore_templates
|
|
Then it should reconstruct the original template syntax
|
|
|
|
Scenario: Restore templates from template blocks
|
|
Given I have configuration with template block markers
|
|
When I restore templates using _restore_templates
|
|
Then it should reconstruct the original template block syntax
|
|
|
|
Scenario: Restore templates from nested dictionaries
|
|
Given I have configuration with nested template structures
|
|
When I restore templates using _restore_templates
|
|
Then it should handle nested dictionaries and lists correctly
|
|
|
|
Scenario: Handle complex template block preprocessing
|
|
Given I have YAML with nested template blocks for preprocessing
|
|
When I preprocess the complex template structure
|
|
Then it should correctly identify and wrap nested template blocks
|
|
|
|
Scenario: Handle template blocks with different indentation levels
|
|
Given I have YAML with template blocks at various indentation levels
|
|
When I preprocess for storage with indented blocks
|
|
Then it should preserve indentation in the processed output
|
|
|
|
Scenario: Handle inline templates in YAML values
|
|
Given I have YAML with inline Jinja templates in values
|
|
When I preprocess for storage with inline values
|
|
Then it should wrap values with template markers and quote them safely
|
|
|
|
Scenario: Handle mixed template blocks and inline templates
|
|
Given I have YAML with both template blocks and inline templates
|
|
When I preprocess the mixed template content
|
|
Then it should handle both types of templates correctly
|
|
|
|
Scenario: Process template blocks with macros
|
|
Given I have YAML with macro template blocks for preprocessor
|
|
When I preprocess for storage with macro blocks
|
|
Then it should correctly identify and process macro blocks
|
|
|
|
Scenario: Handle edge cases in template block detection
|
|
Given I have YAML with edge case template block patterns
|
|
When I preprocess for storage with edge cases
|
|
Then it should handle all template block detection edge cases
|
|
|
|
Scenario: Restore templates with None values
|
|
Given I have configuration with None values and template markers
|
|
When I restore templates with None handling
|
|
Then it should handle None values correctly in template restoration
|
|
|
|
Scenario: Restore templates with list structures
|
|
Given I have configuration with list structures and templates
|
|
When I restore templates from list data
|
|
Then it should correctly handle list structures in template restoration
|
|
|
|
Scenario: Handle parent key detection in template blocks
|
|
Given I have YAML with template blocks requiring parent key detection
|
|
When I preprocess with parent key analysis
|
|
Then it should correctly identify and link template blocks to parent keys
|
|
|
|
Scenario: Handle template block end detection
|
|
Given I have YAML with complex template block endings
|
|
When I preprocess with block end detection
|
|
Then it should correctly identify template block boundaries
|
|
|
|
Scenario: Process multiple template blocks in sequence
|
|
Given I have YAML with multiple sequential template blocks
|
|
When I preprocess multiple template blocks
|
|
Then it should handle each template block independently
|
|
|
|
Scenario: Handle file not found errors in load_file
|
|
Given I have an invalid file path for preprocessor
|
|
When I try to load the file using load_file
|
|
Then it should raise a FileNotFoundError
|
|
|
|
Scenario: Handle empty YAML content in load_string
|
|
Given I have empty YAML content for preprocessor
|
|
When I load the empty content using load_string
|
|
Then it should handle empty content gracefully
|
|
|
|
Scenario: Test template restoration edge cases
|
|
Given I have configuration with various template restoration edge cases
|
|
When I restore templates with edge case handling
|
|
Then it should handle all restoration edge cases correctly |