-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.py
42 lines (36 loc) · 1012 Bytes
/
tests.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
from fastapi.testclient import TestClient
from main import app
client = TestClient(app)
class TestClass:
def test_hello_world(self):
text = "Hello World"
response = client.get("/")
assert response.status_code == 200
assert response.json() == "Hello World"
def test_add_numbers(self):
num1 = 4
num2 = 99
response = client.post(
"/add/",
json={
"num1": 4,
"num2": 99,
},
)
assert response.status_code == 200
assert response.json() == {
"result": "103",
}
def test_join_words(self):
text1 = "Hello"
text2 = "World"
joined_text = "Hello-World"
response = client.post(
"/joinwords/",
json={
"w1": text1,
"w2": text2,
},
)
assert response.status_code == 200
assert response.json() == {"result": joined_text}