-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_main.py
48 lines (41 loc) · 1.25 KB
/
test_main.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
from pydoc import cli
from urllib import response
from fastapi.testclient import TestClient
from main import app
client = TestClient(app)
def test_create_todo():
response = client.post(
"/",
json={ "name": "string",
"description": "string",
"completed": True,
"date": "string"
}
)
assert response.status_code == 200
test_out = response.json()[0]
global test_id
test_id = test_out['id']
assert test_out["name"] == "string"
assert test_out["description"] == "string"
assert test_out["completed"] == True
assert test_out["date"] == "string"
def test_update_todo():
stringexec = '/' + test_id
response = client.put(stringexec,
json={ "name": "string",
"description": "string",
"completed": False,
"date": "string"
})
assert response.status_code == 200
test_out = response.json()[0]
assert test_out["completed"] == False
def test_delete_todo():
stringexec = '/' + test_id
response = client.delete(stringexec)
assert response.status_code == 200
def test_get_todo():
response = client.get('/')
assert response.status_code == 200
assert response.json() == []