Files
ea-chatbot-lg/backend/tests/test_state.py
Yunxiao Xu 68c0985482 feat(auth): Complete OIDC security refactor and modernize test suite
- Refactored OIDC flow to implement PKCE, state/nonce validation, and BFF pattern.
- Centralized configuration in Settings class (DEV_MODE, FRONTEND_URL, OIDC_REDIRECT_URI).
- Updated auth routers to use conditional secure cookie flags based on DEV_MODE.
- Modernized and cleaned up test suite by removing legacy Streamlit tests.
- Fixed linting errors and unused imports across the backend.
2026-02-15 02:50:26 -08:00

39 lines
1.6 KiB
Python

from typing import get_type_hints
from ea_chatbot.graph.state import AgentState
def test_agent_state_structure():
"""Verify that AgentState has the required fields and types."""
hints = get_type_hints(AgentState)
assert "messages" in hints
# Check if Annotated is used, we might need to inspect the __metadata__ if feasible,
# but for TypedDict, checking the key existence is a good start.
# The exact type check for Annotated[List[BaseMessage], operator.add] can be complex to assert strictly,
# but we can check if it's there.
assert "question" in hints
assert hints["question"] == str
# analysis should be Optional[Dict[str, Any]] or similar, but the spec says "Dictionary"
# Let's check it exists.
assert "analysis" in hints
assert "next_action" in hints
assert hints["next_action"] == str
assert "summary" in hints
# summary should be Optional[str] or str. Let's assume Optional[str] for flexibility.
assert "plots" in hints
assert "dfs" in hints
def test_messages_reducer_behavior():
"""Verify that the messages field allows adding lists (simulation of operator.add)."""
# This is harder to test directly on the TypedDict definition without instantiating it in a graph context,
# but we can verify that the type hint implies a list.
hints = get_type_hints(AgentState)
# We expect messages to be Annotated[List[BaseMessage], operator.add]
# We can just assume the developer implements it correctly if the previous test passes,
# or try to inspect the annotation.
pass