-
Notifications
You must be signed in to change notification settings - Fork 24
/
pytest_chatgee.py
71 lines (62 loc) · 1.93 KB
/
pytest_chatgee.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
"""Pytest for ChatGee Server Root"""
# pylint: disable=C0413,W0621
import sys
from unittest.mock import MagicMock
import pytest
sys.path.insert(0, 'chatgee/')
from chatgee.run_server import app
@pytest.fixture
def client():
"""Create a test client for the app"""
with app.test_client() as client:
yield client
def test_prompt(client):
"""Test the '/prompt' route"""
# Mock the ChatGeeOBJ class
ChatGeeOBJ_mock = MagicMock()
# Inject the mocked ChatGeeOBJ instance into the app's context
app.config["ChatGee"] = ChatGeeOBJ_mock
# Send a request to the app's '/prompt' route
test_json = {
"intent": {
"id": "gatfjayew6ss8lkfzmsr7gxz",
"name": "블록 이름"
},
"userRequest": {
"timezone": "Asia/Seoul",
"utterance": "hello there?!",
"params": {
"ignoreMe": "true"
},
"block": {
"id": "gatfjayew6ss8lkfzmsr7gxz",
"name": "블록 이름"
},
"user": {
"id": "677903",
"type": "accountId",
"properties": {}
}
},
"bot": {
"id": "640458f126a0667a7b0d1873",
"name": "봇 이름"
},
"action": {
"name": "m6g1c3el8y",
"params": {
"prompt": "test"
},
"id": "anhh1wxvcs426ebfvt937yam",
"detailParams": {
"prompt": {
"origin": "test",
"value": "test",
"groupName": ""
}
}
}
}
response = client.post("/prompt", json=test_json)
# Verify that the response is as expected
assert response.status_code == 200