Skip to content

Commit 650f864

Browse files
[Chatqna Modular] Updated payload structure (open-edge-platform#1808)
1 parent 18052d6 commit 650f864

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

sample-applications/chat-question-and-answer/tests/unit_tests/conftest.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import pytest
2+
import sys
3+
from types import ModuleType
24
from fastapi.testclient import TestClient
35

6+
chain_stub = ModuleType("app.chain")
7+
chain_stub.process_chunks = lambda *_args, **_kwargs: iter([])
8+
sys.modules["app.chain"] = chain_stub
9+
410
# application packages
511
from app.server import app
612

sample-applications/chat-question-and-answer/tests/unit_tests/test_server.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
def test_query_chain_successful_response(test_client, mocker):
2-
payload = {"input": "What is AI?"}
2+
payload = {
3+
"conversation_messages": [
4+
{"role": "user", "content": "What is AI?"}
5+
],
6+
"max_tokens": 512,
7+
}
38
mocker.patch("app.server.process_chunks", return_value=iter(["one", "two"]))
49
response = test_client.post("/chat", json=payload)
510
assert response.status_code == 200
@@ -13,7 +18,12 @@
1318
assert "two" in streamed_data
1419

1520
def test_query_chain_no_input(test_client):
16-
payload = {"input": ""}
21+
payload = {
22+
"conversation_messages": [
23+
{"role": "user", "content": ""}
24+
],
25+
"max_tokens": 512,
26+
}
1727
response = test_client.post("/chat", json=payload)
1828
assert response.status_code == 422
1929
assert response.json() == {"detail": "Question is required"}

0 commit comments

Comments
 (0)