Files
cleveractors-core/features/stream_router_final_coverage.feature
CoreRasurae 9753b31c7e
CI / quality (push) Successful in 36s
CI / lint (push) Successful in 38s
CI / typecheck (push) Successful in 49s
CI / security (push) Successful in 51s
CI / integration_tests (push) Successful in 55s
CI / unit_tests (push) Successful in 3m35s
CI / build (push) Successful in 33s
CI / coverage (push) Successful in 3m36s
CI / status-check (push) Successful in 3s
test: add coverage gap tests improving coverage from 81.4% to 96.90%
Add 13 BDD scenarios covering previously uncovered code paths:
- SAFE_BUILTINS validation (sandbox.py: 0% → 100%)
- ConfigurationError re-raise path (config.py: 99.3% → 100%)
- CLI hello/main functions (cli.py: 72.7% → 90.9%)
- GraphState message truncation (state.py: 98.7% → 100%)
- ProgressBarManager update/context rendering (progress.py: 0% → 87.7%)
- MessageRouter regex/exact/contains routing (message_router.py: 0% → 59.4%)
- RoutingAdapter parse_routing_command (routing_adapter.py)
- DynamicRouterNode pattern-based routing (dynamic_router.py)
- EnhancedTemplateRegistry unknown template type (enhanced_registry.py: 99.2%)
- CompositeAgent null-graph error path (composite.py: 97.8% → 98.6%)

Cover routing_adapter.py (17% → 100%): all GOTO/ROUTE patterns,
create_routing_node, create_conditional_router, dynamic config conversion.

Cover dynamic_router.py (21% → 87%): execute with empty/dict/string
messages, extract_message with colon parsing, config creation, graph
extension with edge generation.

Cover message_router.py (59% → 78%): regex, exact, contains, prefix,
suffix match types, invalid regex handling, non-string message, set_state.

Exercise Node._prepare_conversation_history with invalid configs,
_runtime error paths, _execute_message_router with rules,
_execute_agent with current_message and metadata propagation,
_execute_function with dynamic_router, and _execute_conditional
with content_contains/content_not_contains/content_starts_with
and custom condition types. Improves nodes.py from 71.3% to 72.5%.

Exercise PureGraphConfig, PureLangGraph init with dict/config,
RxPyLangGraphBridge registration/connection/lookup,
ReactiveStreamRouter operator creation and condition functions,
ReactiveConfigParser config/route/graph parsing,
ToolAgent tool execution with JSON, space-separated, single,
file_read, progress_bar invocations, and
ReactiveCleverAgentsApp init/dispose/visualization.
2026-06-02 20:02:01 +01:00

68 lines
3.4 KiB
Gherkin

Feature: StreamMessage Copy, Agent Mapper Context, and Accumulator Edge Cases
As a developer
I want stream messages to copy with metadata, agent mapper to use global context, and accumulators to handle non-numeric content
So that stream message propagation and context management works correctly in edge cases
Background:
Given a fresh stream router final test context (srv)
Scenario: StreamMessage copy_with with dict metadata copies non-context keys
Given a StreamMessage with metadata containing context and other keys (srv)
When I call copy_with preserving context reference (srv)
Then non-context metadata values should be deep-copied (srv)
And context reference should be preserved (srv)
Scenario: create_stream raises for duplicate stream name
Given a stream router with a "dup_stream" already registered (srv)
When I create another stream named "dup_stream" (srv)
Then a StreamRoutingError should be raised (srv)
Scenario: Transform operator with message content attribute
Given a stream router configured with transform fn operator (srv)
When I send a message through the transform stream (srv)
Then the transform function should process the content attribute (srv)
Scenario: Switch with case-level inline operators
Given a stream router with switch operators for inline case test (srv)
When a message matches a case with inline operators (srv)
Then the inline operators should be applied (srv)
Scenario: Switch default operators applied when no case matches
Given a stream router with switch default operators test (srv)
When a message matches no case and default operators exist (srv)
Then the default operators should be applied (srv)
Scenario: Switch default stream routing when no case matches
Given a stream router with switch default stream test (srv)
When a message matches no case and default stream exists (srv)
Then the message should route to the default stream (srv)
Scenario: Agent mapper uses _global_context_ref when metadata has no context
Given a stream router with _global_context_ref set (srv)
When an agent mapper processes a message without context in metadata (srv)
Then the _global_context_ref should be used as context (srv)
Scenario: Agent mapper handles None message input
Given a stream router with a registered agent "handler" (srv)
When the agent mapper receives a None message (srv)
Then it should return a StreamMessage without crashing (srv)
Scenario: Agent mapper handles processing timeout
Given a stream router with a registered agent "slow_agent" (srv)
When the agent mapper processes a message with timeout (srv)
Then a timeout message should be returned (srv)
Scenario: send_message gets timestamp without running event loop
Given a stream router with a "custom" stream (srv)
When send_message is called with no running event loop (srv)
Then time.time() should be used for the timestamp (srv)
Scenario: _apply_accumulator sum with non-numeric content
Given a stream router configured for accumulator testing (srv)
When _apply_accumulator sum receives non-numeric content (srv)
Then the accumulator should return unchanged value (srv)
Scenario: _apply_accumulator with unknown type returns accumulator
Given a stream router configured for accumulator testing (srv)
When _apply_accumulator receives unknown type (srv)
Then the accumulator should be returned unchanged (srv)