195 lines
8.8 KiB
Gherkin
195 lines
8.8 KiB
Gherkin
Feature: Template Registry Module Coverage
|
|
As a developer
|
|
I want to test all functionality in the template registry module
|
|
So that we achieve 90%+ code coverage for the registry.py file
|
|
|
|
Background:
|
|
Given I have a clean test environment for registry
|
|
|
|
Scenario: Test TemplateRegistry initialization
|
|
Given I create a new template registry
|
|
Then the registry should be initialized correctly
|
|
And all template type collections should be empty
|
|
|
|
Scenario: Test register_template - normal agent template
|
|
Given I have a template registry for registry testing
|
|
And I have a normal agent template definition
|
|
When I register the agent template
|
|
Then the agent template should be stored correctly
|
|
And logging should record the registration
|
|
|
|
Scenario: Test register_template - composite agent template
|
|
Given I have a template registry for registry testing
|
|
And I have a composite agent template definition
|
|
When I register the composite agent template
|
|
Then the composite agent template should be stored correctly
|
|
And logging should record the registration
|
|
|
|
Scenario: Test register_template - graph template
|
|
Given I have a template registry for registry testing
|
|
And I have a graph template definition
|
|
When I register the graph template
|
|
Then the graph template should be stored correctly
|
|
And logging should record the registration
|
|
|
|
Scenario: Test register_template - stream template
|
|
Given I have a template registry for registry testing
|
|
And I have a stream template definition
|
|
When I register the stream template
|
|
Then the stream template should be stored correctly
|
|
And logging should record the registration
|
|
|
|
Scenario: Test register_template - invalid template type
|
|
Given I have a template registry for registry testing
|
|
And I have an invalid template definition
|
|
When I try to register the invalid template
|
|
Then a ValueError should be raised for registry
|
|
And the error message should mention unknown template type
|
|
|
|
Scenario: Test get_template - successful retrieval
|
|
Given I have a template registry for registry testing
|
|
And I have registered templates of all types
|
|
When I retrieve a template by type and name
|
|
Then the correct template should be returned
|
|
|
|
Scenario: Test get_template - template not found
|
|
Given I have a template registry for registry testing
|
|
When I try to retrieve a non-existent template
|
|
Then a ValueError should be raised for registry
|
|
And the error message should mention template not found
|
|
|
|
Scenario: Test has_template - template exists
|
|
Given I have a template registry for registry testing
|
|
And I have registered a test template
|
|
When I check if the template exists
|
|
Then the result should be true for registry
|
|
|
|
Scenario: Test has_template - template does not exist
|
|
Given I have a template registry for registry testing
|
|
When I check if a non-existent template exists
|
|
Then the result should be false for registry
|
|
|
|
Scenario: Test instantiate - with context provided
|
|
Given I have a template registry for registry testing
|
|
And I have registered a template for instantiation
|
|
And I have an instantiation context for registry
|
|
When I instantiate the template with context
|
|
Then the template should be instantiated correctly
|
|
And the provided context should be used
|
|
|
|
Scenario: Test instantiate - without context provided
|
|
Given I have a template registry for registry testing
|
|
And I have registered a template for instantiation
|
|
When I instantiate the template without context
|
|
Then the template should be instantiated correctly
|
|
And a new context should be created automatically
|
|
|
|
Scenario: Test instantiate_from_config - None config
|
|
Given I have a template registry for registry testing
|
|
When I try to instantiate from None config
|
|
Then a ValueError should be raised for registry
|
|
And the error message should mention None configuration
|
|
|
|
Scenario: Test instantiate_from_config - template-based with found template
|
|
Given I have a template registry for registry testing
|
|
And I have registered templates for config instantiation
|
|
And I have a config with template reference
|
|
When I instantiate from the template config
|
|
Then the correct template should be instantiated
|
|
And the template parameters should be applied
|
|
|
|
Scenario: Test instantiate_from_config - template-based with template not found
|
|
Given I have a template registry for registry testing
|
|
And I have a config with non-existent template reference
|
|
When I try to instantiate from the invalid template config
|
|
Then a ValueError should be raised for registry
|
|
And the error message should mention template not found in config
|
|
|
|
Scenario: Test instantiate_from_config - agent_template specific
|
|
Given I have a template registry for registry testing
|
|
And I have registered an agent template
|
|
And I have a config with agent_template reference
|
|
When I instantiate from the agent template config
|
|
Then the agent template should be instantiated correctly
|
|
|
|
Scenario: Test instantiate_from_config - graph_template specific
|
|
Given I have a template registry for registry testing
|
|
And I have registered a graph template
|
|
And I have a config with graph_template reference
|
|
When I instantiate from the graph template config
|
|
Then the graph template should be instantiated correctly
|
|
|
|
Scenario: Test instantiate_from_config - stream_template specific
|
|
Given I have a template registry for registry testing
|
|
And I have registered a stream template
|
|
And I have a config with stream_template reference
|
|
When I instantiate from the stream template config
|
|
Then the stream template should be instantiated correctly
|
|
|
|
Scenario: Test instantiate_from_config - direct agent definition
|
|
Given I have a template registry for registry testing
|
|
And I have a config with direct agent definition
|
|
When I instantiate from the direct agent config
|
|
Then None should be returned for agent factory handling
|
|
|
|
Scenario: Test instantiate_from_config - direct graph definition
|
|
Given I have a template registry for registry testing
|
|
And I have a config with direct graph definition
|
|
When I instantiate from the direct graph config
|
|
Then a GraphConfig should be returned
|
|
|
|
Scenario: Test instantiate_from_config - direct stream definition
|
|
Given I have a template registry for registry testing
|
|
And I have a config with direct stream definition
|
|
When I instantiate from the direct stream config
|
|
Then a StreamConfig should be returned
|
|
|
|
Scenario: Test instantiate_from_config - unrecognized config
|
|
Given I have a template registry for registry testing
|
|
And I have an unrecognizable config
|
|
When I try to instantiate from the unrecognizable config
|
|
Then a ValueError should be raised for registry
|
|
And the error message should mention cannot determine instance type
|
|
|
|
Scenario: Test instantiate_from_config - without context provided
|
|
Given I have a template registry for registry testing
|
|
And I have registered templates for config instantiation
|
|
And I have a config with template reference
|
|
When I instantiate from config without context
|
|
Then the instantiation should succeed
|
|
And a new context should be created automatically
|
|
|
|
Scenario: Test register_all_templates - comprehensive registration
|
|
Given I have a template registry for registry testing
|
|
And I have a comprehensive templates configuration
|
|
When I register all templates from the configuration
|
|
Then all agent templates should be registered correctly
|
|
And all graph templates should be registered correctly
|
|
And all stream templates should be registered correctly
|
|
|
|
Scenario: Test register_all_templates - empty configuration sections
|
|
Given I have a template registry for registry testing
|
|
And I have an empty templates configuration
|
|
When I register all templates from the empty configuration
|
|
Then no templates should be registered
|
|
And the registry should remain empty
|
|
|
|
Scenario: Test list_templates - all template types
|
|
Given I have a template registry for registry testing
|
|
And I have registered templates of all types
|
|
When I list all templates
|
|
Then all template types should be included in the result
|
|
And each type should show its registered templates
|
|
|
|
Scenario: Test list_templates - specific template type filter
|
|
Given I have a template registry for registry testing
|
|
And I have registered templates of all types
|
|
When I list templates for a specific type
|
|
Then only that template type should be included in the result
|
|
And it should show the correct registered templates
|
|
|
|
Scenario: Test list_templates - empty registry
|
|
Given I have a template registry for registry testing
|
|
When I list all templates from empty registry
|
|
Then all template types should be present but empty
|
|
And no templates should be listed |