fix(tui): add preset count assertion and actor lookup exception test
CI / helm (pull_request) Successful in 38s
CI / build (pull_request) Successful in 1m3s
CI / push-validation (pull_request) Successful in 48s
CI / lint (pull_request) Successful in 1m14s
CI / typecheck (pull_request) Successful in 1m35s
CI / quality (pull_request) Successful in 1m51s
CI / security (pull_request) Successful in 1m53s
CI / integration_tests (pull_request) Successful in 4m9s
CI / e2e_tests (pull_request) Successful in 4m28s
CI / unit_tests (pull_request) Failing after 5m35s
CI / docker (pull_request) Has been skipped
CI / coverage (pull_request) Successful in 13m30s
CI / status-check (pull_request) Failing after 4s

Address reviewer feedback:
- Add exact preset count assertion (3 presets) to thinking_effort-only
  scenario to verify no extra presets are generated
- Add BDD scenario for actor lookup exception path to verify graceful
  fallback to default-only preset when get_actor() raises an exception
- Add step definition for plural 'presets' form to support count > 1
- Add step definition for actor service that raises on get_actor

ISSUES CLOSED: #9360
This commit is contained in:
CleverThis
2026-05-04 20:12:50 +00:00
committed by CleverThis
parent a6fe802f75
commit c58c498a23
3 changed files with 23 additions and 7 deletions
+13 -4
View File
@@ -536,7 +536,9 @@ def step_actor_service_with_temperature(context: object, actor: str) -> None:
context._actor_service = mock_service
@given('an actor service with a mock actor "{actor}" with thinking_effort and temperature arguments')
@given(
'an actor service with a mock actor "{actor}" with thinking_effort and temperature arguments'
)
def step_actor_service_with_both(context: object, actor: str) -> None:
from cleveragents.domain.models.core import Actor
@@ -580,6 +582,13 @@ def step_actor_service_with_no_args(context: object, actor: str) -> None:
context._actor_service = mock_service
@given("an actor service that raises an exception on get_actor")
def step_actor_service_raises_exception(context: object) -> None:
mock_service = MagicMock()
mock_service.get_actor.side_effect = RuntimeError("Actor not found")
context._actor_service = mock_service
@when('I call create_default_persona_for_actor with actor "{actor}" and actor_service')
def step_create_persona_with_service(context: object, actor: str) -> None:
from cleveragents.tui.first_run import create_default_persona_for_actor
@@ -595,12 +604,12 @@ def step_persona_has_preset(context: object, preset_name: str) -> None:
assert persona is not None, "Expected persona 'default' in registry"
preset_names = [p.name for p in persona.argument_presets]
assert preset_name in preset_names, (
f"Expected preset '{preset_name}' in persona presets, "
f"got: {preset_names}"
f"Expected preset '{preset_name}' in persona presets, got: {preset_names}"
)
@then('the default persona should have exactly {count:d} preset')
@then("the default persona should have exactly {count:d} preset")
@then("the default persona should have exactly {count:d} presets")
def step_persona_has_exact_presets(context: object, count: int) -> None:
persona = context._registry.get("default")
assert persona is not None, "Expected persona 'default' in registry"
+9
View File
@@ -207,6 +207,7 @@ Feature: TUI first-run experience with actor selection overlay
And the default persona should have preset "default"
And the default persona should have preset "think: high"
And the default persona should have preset "think: max"
And the default persona should have exactly 3 presets
Scenario: create_default_persona_for_actor auto-generates presets for actor with temperature
Given an empty persona registry
@@ -242,3 +243,11 @@ Feature: TUI first-run experience with actor selection overlay
Then the registry should contain a persona named "default"
And the default persona should have preset "default"
And the default persona should have exactly 1 preset
Scenario: create_default_persona_for_actor falls back to default preset when actor lookup fails
Given an empty persona registry
And an actor service that raises an exception on get_actor
When I call create_default_persona_for_actor with actor "anthropic/claude-4-sonnet" and actor_service
Then the registry should contain a persona named "default"
And the default persona should have preset "default"
And the default persona should have exactly 1 preset
+1 -3
View File
@@ -148,9 +148,7 @@ def create_default_persona_for_actor(
presets = _auto_generate_presets(actor_service, actor)
else:
# Default to just the default preset
presets = [
PersonaPreset(name="default", display="default", overrides={})
]
presets = [PersonaPreset(name="default", display="default", overrides={})]
persona = Persona(
name="default",