Spaces:
Sleeping
Sleeping
| """Unit tests for route_after_evaluation — no LLM, no DB needed.""" | |
| from backend.graph.nodes import route_after_evaluation | |
| def _state(**overrides) -> dict: | |
| """Build a minimal InterviewState dict for routing tests.""" | |
| base = { | |
| "last_verdict": "strong", | |
| "turn_count": 1, | |
| "questions_remaining": [{"question_text": "Q2", "difficulty": "easy"}], | |
| "awaiting_counter_response": False, | |
| } | |
| base.update(overrides) | |
| return base | |
| def test_shallow_not_in_counter_loop_routes_to_counter(): | |
| state = _state(last_verdict="shallow", awaiting_counter_response=False) | |
| assert route_after_evaluation(state) == "counter" | |
| def test_shallow_already_in_counter_loop_routes_to_next_question(): | |
| state = _state(last_verdict="shallow", awaiting_counter_response=True, turn_count=2) | |
| assert route_after_evaluation(state) == "next_question" | |
| def test_strong_routes_to_next_question(): | |
| state = _state(last_verdict="strong", turn_count=1) | |
| assert route_after_evaluation(state) == "next_question" | |
| def test_wrong_routes_to_next_question(): | |
| state = _state(last_verdict="wrong", turn_count=1) | |
| assert route_after_evaluation(state) == "next_question" | |
| def test_turn_count_8_routes_to_end(): | |
| state = _state(last_verdict="strong", turn_count=8) | |
| assert route_after_evaluation(state) == "end" | |
| def test_no_questions_remaining_routes_to_end(): | |
| state = _state(last_verdict="strong", turn_count=3, questions_remaining=[]) | |
| assert route_after_evaluation(state) == "end" | |
| def test_every_4_turns_routes_to_summarize(): | |
| state = _state(last_verdict="strong", turn_count=4) | |
| assert route_after_evaluation(state) == "summarize" | |
| def test_turn_8_beats_summarize(): | |
| # turn_count=8 should end, not summarize (end takes priority) | |
| state = _state(last_verdict="strong", turn_count=8) | |
| assert route_after_evaluation(state) == "end" | |