Files
cleveragents-core/tests/features/stream_router_comprehensive.feature

411 lines
10 KiB
Gherkin

Feature: Stream Router Coverage Testing
As a developer
I want to test specific functionality in the stream router module
So that we achieve better code coverage for the stream_router.py file
Background:
Given the CleverAgents reactive system is available
Scenario: Create replay stream with buffer size
Given I have a replay stream configuration:
"""
{
"name": "replay_stream",
"type": "replay",
"buffer_size": 5,
"operators": []
}
"""
When I create the reactive stream
Then the stream should be created successfully
Scenario: Create hot stream with initial value
Given I have a hot stream configuration:
"""
{
"name": "hot_stream",
"type": "hot",
"initial_value": "initial_data",
"operators": []
}
"""
When I create the reactive stream
Then the stream should be created successfully
Scenario: Stream creation with existing name should fail
Given I have a stream configuration:
"""
{
"name": "existing_stream",
"type": "cold",
"operators": []
}
"""
When I create the reactive stream
And I try to create another stream with the same name
Then I should get a stream routing error
Scenario: Create agent mapper with tool agent
Given I have a tool agent named "echo_agent" with echo tool
And I have a stream configuration with agent mapper:
"""
{
"name": "agent_stream",
"type": "cold",
"operators": [
{
"type": "map",
"params": {
"agent": "echo_agent"
}
}
]
}
"""
When I create the reactive stream
Then the stream should be created successfully
Scenario: Create agent mapper with missing agent should fail
Given I have a stream configuration with missing agent:
"""
{
"name": "missing_agent_stream",
"type": "cold",
"operators": [
{
"type": "map",
"params": {
"agent": "nonexistent_agent"
}
}
]
}
"""
When I try to create the reactive stream
Then I should get a stream routing error about missing agent
Scenario: Transform operator with extract transform
Given I have a stream configuration with extract transform:
"""
{
"name": "extract_stream",
"type": "cold",
"operators": [
{
"type": "map",
"params": {
"transform": {
"type": "extract",
"field": "data"
}
}
}
]
}
"""
When I create the reactive stream
And I send a dictionary message with field "data"
Then the field value should be extracted
Scenario: Transform operator with wrap transform
Given I have a stream configuration with wrap transform:
"""
{
"name": "wrap_stream",
"type": "cold",
"operators": [
{
"type": "map",
"params": {
"transform": {
"type": "wrap",
"wrapper": {"status": "processed"}
}
}
}
]
}
"""
When I create the reactive stream
Then the stream should be created successfully
Scenario: Transform operator with format transform
Given I have a stream configuration with format transform:
"""
{
"name": "format_stream",
"type": "cold",
"operators": [
{
"type": "map",
"params": {
"transform": {
"type": "format",
"template": "Result: {content}"
}
}
}
]
}
"""
When I create the reactive stream
Then the stream should be created successfully
Scenario: Unknown operator should fail
Given I have a stream configuration with unknown operator:
"""
{
"name": "unknown_stream",
"type": "cold",
"operators": [
{
"type": "unknown_operator"
}
]
}
"""
When I try to create the reactive stream
Then I should get a stream routing error about unknown operator
Scenario: LangGraph operators without bridge should fail
Given I have a stream configuration with LangGraph operator for router testing:
"""
{
"name": "langgraph_stream",
"type": "cold",
"operators": [
{
"type": "graph_execute",
"params": {}
}
]
}
"""
When I try to create the reactive stream
Then I should get a stream routing error about LangGraph bridge
Scenario: Stream message copy_with functionality
Given I have a stream message for router testing
When I copy the message with modifications
Then the new message should have the modifications
And the original message should be unchanged
Scenario: Agent mapper with None message handling
Given I have a tool agent named "test_agent" with echo tool
When I process a None message through the agent mapper
Then the agent should handle None gracefully
Scenario: Stream disposal
Given I have a stream for router testing
When I dispose of the stream router
Then the stream router should be disposed properly
Scenario: Message with timestamp
Given I have a stream for router testing
When I send a message to check timestamp
Then the message should have a timestamp
Scenario: Filter operator with never condition
Given I have a stream configuration with never filter:
"""
{
"name": "never_filter",
"type": "cold",
"operators": [
{
"type": "filter",
"params": {
"condition": {
"type": "never"
}
}
}
]
}
"""
When I create the reactive stream
Then the stream should be created successfully
Scenario: Filter operator with metadata condition
Given I have a stream configuration with metadata condition:
"""
{
"name": "metadata_condition_filter",
"type": "cold",
"operators": [
{
"type": "filter",
"params": {
"condition": {
"type": "metadata_has",
"key": "test_key"
}
}
}
]
}
"""
When I create the reactive stream
Then the stream should be created successfully
Scenario: Filter operator with source condition
Given I have a stream configuration with source condition:
"""
{
"name": "source_condition_filter",
"type": "cold",
"operators": [
{
"type": "filter",
"params": {
"condition": {
"type": "source_is",
"source": "test_source"
}
}
}
]
}
"""
When I create the reactive stream
Then the stream should be created successfully
Scenario: Transform with identity type
Given I have a stream configuration with identity transform:
"""
{
"name": "identity_stream",
"type": "cold",
"operators": [
{
"type": "map",
"params": {
"transform": {
"type": "identity"
}
}
}
]
}
"""
When I create the reactive stream
Then the stream should be created successfully
Scenario: Accumulator with collect type
Given I have a stream configuration with collect accumulator:
"""
{
"name": "collect_stream",
"type": "cold",
"operators": [
{
"type": "scan",
"params": {
"accumulator": {
"type": "collect"
}
}
}
]
}
"""
When I create the reactive stream
Then the stream should be created successfully
Scenario: Accumulator with concat type
Given I have a stream configuration with concat accumulator:
"""
{
"name": "concat_stream",
"type": "cold",
"operators": [
{
"type": "scan",
"params": {
"accumulator": {
"type": "concat"
}
}
}
]
}
"""
When I create the reactive stream
Then the stream should be created successfully
Scenario: Utility operators all types
Given I have a stream configuration with all utility operators:
"""
{
"name": "all_utility_stream",
"type": "cold",
"operators": [
{
"type": "distinct"
},
{
"type": "take",
"params": {
"count": 3
}
},
{
"type": "skip",
"params": {
"count": 1
}
},
{
"type": "sample",
"params": {
"interval": 0.5
}
}
]
}
"""
When I create the reactive stream
Then the stream should be created successfully
Scenario: Error handling with retry
Given I have a stream configuration with retry:
"""
{
"name": "retry_stream",
"type": "cold",
"operators": [
{
"type": "retry",
"params": {
"count": 2
}
}
]
}
"""
When I create the reactive stream
Then the stream should be created successfully
Scenario: Stream merge with existing output
Given I have an existing output stream
When I try to merge streams into existing output
Then the merge should work with existing stream
Scenario: Stream split with conditions
Given I have a stream for splitting
When I split with multiple conditions
Then the split should create multiple output streams
Scenario: Send message to nonexistent stream
When I try to send message to missing stream
Then I should get stream routing error for missing stream
Scenario: Subscribe to output stream
Given I have a stream for router testing
When I subscribe to the output stream
Then the subscription should be successful
Scenario: Handle stream error
Given I have a stream for router testing
When I trigger a stream error
Then the error should be handled properly