-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_logic.py
34 lines (28 loc) · 1.03 KB
/
test_logic.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
from fastapi.testclient import TestClient
from main import app
from mylib.controllers.wiki import wiki, search_wiki
client = TestClient(app)
def test_wiki():
assert "god" in wiki()
assert "Barack" in wiki(name="barak")
def test_read_main():
response = client.get("/")
assert response.status_code == 200
assert response.json() == {"message": "Hello, World!"}
def test_healthcheck():
ping_response = client.get("/healthcheck/ping")
ready_response = client.get("/healthcheck/ready")
assert ping_response.status_code == 200
assert ping_response.json() == "ok"
assert ready_response.status_code == 200
assert ready_response.json() == "ready"
def test_wiki_main():
result = wiki("god")
response = client.get("/wiki/god")
assert response.status_code == 200
assert response.json() == {"message": result}
def test_wiki_search():
result = search_wiki("god")
response = client.get("/wiki/search/god")
assert response.status_code == 200
assert response.json() == {"message": result}