feat(api): Implement create conversation endpoint

This commit is contained in:
Yunxiao Xu
2026-02-11 16:09:22 -08:00
parent b7abdfe457
commit ceddacf9cb
3 changed files with 48 additions and 1 deletions

View File

@@ -41,6 +41,27 @@ def test_get_conversations_success(auth_header, mock_user):
assert len(response.json()) == 1
assert response.json()[0]["name"] == "Conv 1"
def test_create_conversation_success(auth_header, mock_user):
"""Test creating a new conversation."""
with patch("ea_chatbot.api.routers.history.history_manager") as mock_hm:
mock_hm.create_conversation.return_value = Conversation(
id="c2",
name="New Conv",
user_id=mock_user.id,
data_state="nj",
created_at=datetime.now(timezone.utc)
)
response = client.post(
"/conversations",
json={"name": "New Conv"},
headers=auth_header
)
assert response.status_code == 201
assert response.json()["name"] == "New Conv"
assert response.json()["id"] == "c2"
def test_get_messages_success(auth_header):
"""Test retrieving messages for a conversation."""
with patch("ea_chatbot.api.routers.history.history_manager") as mock_hm: