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

116 lines
4.8 KiB
Gherkin

Feature: State Management Missing Coverage
As a developer
I want to test specific uncovered code paths in state.py
So that we achieve complete coverage
Background:
Given the state management system is available
Scenario: GraphState REPLACE mode with non-existent attribute
Given I have a GraphState instance
And I have updates with non-existent attributes only
When I update the state with REPLACE mode for nonexistent attributes
Then non-existent attributes should be ignored
And hasattr check should be performed for each attribute
Scenario: GraphState MERGE mode with non-dict non-list value
Given I have a GraphState with string metadata
And I have string updates for merge mode
When I update the state with MERGE mode for string values
Then the simple value should replace the existing value
And line 76 should be executed
Scenario: GraphState APPEND mode with single item to list
Given I have a GraphState with list messages
And I have single item to append to list field
When I update the state with APPEND mode for string field
Then the single item should be set as new value
And line 85 should be executed for non-list field
Scenario: Direct GraphState from_dict method call
Given I have a complete state dictionary
When I call GraphState.from_dict class method directly
Then a new GraphState instance should be created
And line 100 should be executed
And all attributes should be properly set
Scenario: StateManager history trimming with exact max size
Given I have a StateManager with time travel enabled
And I set max history to exactly 2
When I make exactly 3 state updates
Then history should be trimmed to 2 entries
And line 159 should be executed for trimming
Scenario: StateManager automatic checkpoint saving
Given I have a StateManager with checkpointing and small interval
And I set checkpoint interval to 2
When I make exactly 2 state updates
Then checkpoint should be saved automatically
And line 171 should be executed for checkpoint trigger
Scenario: StateManager with no checkpoint directory
Given I have a StateManager without checkpoint directory
When I trigger checkpoint saving
Then _save_checkpoint should return early
And lines 177-178 should be executed
Scenario: StateManager checkpoint loading from file
Given I have a StateManager with checkpoint directory
And I have a valid checkpoint file
When I load checkpoint from the file
Then state should be restored from checkpoint data
And lines 195-204 should be executed
And GraphState.from_dict should be called
Scenario: StateManager get latest checkpoint from directory
Given I have a StateManager with checkpoint directory
And I have checkpoint files in the directory
When I get the latest checkpoint from directory
Then the most recent file should be returned
And lines 208-215 should be executed
Scenario: StateManager get latest checkpoint with no directory
Given I have a StateManager without checkpoint directory for latest check
When I get the latest checkpoint with no directory
Then None should be returned immediately
And line 209 should be executed
Scenario: StateManager time travel with history
Given I have a StateManager with time travel and history
And I have made multiple state updates with history
When I perform time travel operation
Then state should revert to historical snapshot
And lines 219-231 should be executed
And GraphState.from_dict should be called for restoration
Scenario: StateManager time travel with steps beyond history
Given I have a StateManager with limited time travel history
When I try to time travel beyond available history
Then it should travel to earliest available state
And steps should be clamped to history length
Scenario: StateManager get state observable method
Given I have a StateManager
When I call get_state_observable method
Then the behavior subject should be returned
And line 235 should be executed
Scenario: StateManager clear history method
Given I have a StateManager with existing history
When I call clear_history method
Then history list should be emptied
And line 239 should be executed
Scenario: StateManager reset with no initial state
Given I have a StateManager with modified state
When I call reset with no parameters
Then state should reset to default GraphState
And lines 243-248 should be executed
And state stream should emit reset state
Scenario: StateManager reset with custom initial state
Given I have a StateManager
And I have a custom GraphState instance
When I call reset with the custom initial state
Then state should be set to the custom instance
And reset operations should be performed