1
- import pytest
2
- from fastapi .testclient import TestClient
3
1
from app .app import app
2
+ from fastapi .testclient import TestClient
3
+ import pytest
4
4
5
5
# Initialize the test client
6
6
client = TestClient (app )
7
7
8
+
8
9
@pytest .mark .asyncio
9
10
async def test_list_functions ():
10
11
"""Test listing available functions."""
11
12
# Test splitter results
12
13
response = client .get ("/" , headers = {"api-key" : "test_api_key" })
13
14
assert response .status_code == 200
14
15
response_data = response .json ()
15
-
16
+
16
17
expected_response_start = [
17
18
{
18
19
"name" : "split_ppt" ,
19
20
"path" : "/splitter/ppt" ,
20
21
"inputs" : [
21
22
{"name" : "document_content" , "type" : "string(binary)" },
22
23
{"name" : "chunk_size" , "type" : "integer" },
23
- {"name" : "chunk_overlap" , "type" : "integer" }
24
+ {"name" : "chunk_overlap" , "type" : "integer" },
24
25
],
25
- "outputs" : [
26
- {"name" : "chunks" , "type" : "array<string>" }
27
- ],
28
- "definitions" : {}
26
+ "outputs" : [{"name" : "chunks" , "type" : "array<string>" }],
27
+ "definitions" : {},
29
28
},
30
29
{
31
30
"name" : "split_py" ,
32
31
"path" : "/splitter/py" ,
33
32
"inputs" : [
34
33
{"name" : "document_content" , "type" : "string(binary)" },
35
34
{"name" : "chunk_size" , "type" : "integer" },
36
- {"name" : "chunk_overlap" , "type" : "integer" }
37
- ],
38
- "outputs" : [
39
- {"name" : "chunks" , "type" : "array<string>" }
35
+ {"name" : "chunk_overlap" , "type" : "integer" },
40
36
],
41
- "definitions" : {}
37
+ "outputs" : [{"name" : "chunks" , "type" : "array<string>" }],
38
+ "definitions" : {},
42
39
},
43
40
{
44
41
"name" : "split_pdf" ,
45
42
"path" : "/splitter/pdf" ,
46
43
"inputs" : [
47
44
{"name" : "document_content" , "type" : "string(binary)" },
48
45
{"name" : "chunk_size" , "type" : "integer" },
49
- {"name" : "chunk_overlap" , "type" : "integer" }
50
- ],
51
- "outputs" : [
52
- {"name" : "chunks" , "type" : "array<string>" }
46
+ {"name" : "chunk_overlap" , "type" : "integer" },
53
47
],
54
- "definitions" : {}
55
- }
48
+ "outputs" : [{"name" : "chunks" , "type" : "array<string>" }],
49
+ "definitions" : {},
50
+ },
56
51
]
57
52
58
53
assert response_data [:3 ] == expected_response_start
@@ -61,4 +56,3 @@ async def test_list_functions():
61
56
response = client .get ("/" , headers = {"api-key" : "invalid_api_key" })
62
57
assert response .status_code == 401
63
58
assert response .json () == {"detail" : "Invalid API key" }
64
-
0 commit comments