-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver_test.py
51 lines (44 loc) · 1.51 KB
/
server_test.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
import pytest
from fastapi.testclient import TestClient
from app.server import Server
from app.models.models import (
TextIngestionRequest,
ImageIngestionRequest,
AssessmentRequest,
)
import requests
def test_server():
client = "http://localhost:8000"
fake_user_id = "1234567890"
print(f"Testing server with user id: {fake_user_id}")
# Test text ingestion
text_request = TextIngestionRequest(
userId=fake_user_id,
text="This is a test text",
source="test",
language="en",
isUsersCreation=True,
)
print(f"Testing text ingestion with request: {text_request}")
response = requests.post(
f"{client}/add_text_source", json=text_request.dict()
)
print(f"Text ingestion response: {response.json()}")
# Test image ingestion
image_request = ImageIngestionRequest(
userId=fake_user_id,
image_url="https://picsum.photos/500",
)
print(f"Testing image ingestion with request: {image_request}")
response = requests.post(
f"{client}/add_image_and_maybe_text_source", json=image_request.dict()
)
print(f"Image ingestion response: {response.json()}")
# Test getting a summary
assessment_request = AssessmentRequest(userId=fake_user_id)
print(f"Testing summary generation with request: {assessment_request}")
response = requests.post(
f"{client}/summarize_profile", json=assessment_request.dict()
)
print(f"Summary generation response: {response.json()}")
test_server()