-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtest_main.py
41 lines (32 loc) Β· 1.4 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
from fastapi.testclient import TestClient
from main import app
client = TestClient(app)
def test_correct_post():
timetable_id = 1
course_code = "CS101"
response = client.post(
url=f'/api/v1/timetables/{timetable_id}',
json={"courseCode": course_code})
#print(response.json())
assert response.json() == {"success" : True, "data" : None, "error" : None}
def test_correct_timetable_incorrect_coursecode_post():
timetable_id = 1
course_code = "Bad Course Code"
response = client.post(
url=f'/api/v1/timetables/{timetable_id}',
json={"courseCode": course_code})
assert response.json() == {'success': False, 'data': None, 'error': 'κ°μκ° μ‘΄μ¬νμ§ μμ΅λλ€.'}
def test_incorrect_timetable_correct_coursecode_post():
timetable_id = 4
course_code = "CS101"
response = client.post(
url=f'/api/v1/timetables/{timetable_id}',
json={"courseCode": course_code})
assert response.json() == {'success': False, 'data': None, 'error': "μκ°νκ° μ‘΄μ¬νμ§ μμ΅λλ€."}
def test_incorrect_timetable_incorrect_coursecode_post():
timetable_id = 4
course_code = "Bad Course Code"
response = client.post(
url=f'/api/v1/timetables/{timetable_id}',
json={"courseCode": course_code})
assert response.json() == {'success': False, 'data': None, 'error': "μκ°νκ° μ‘΄μ¬νμ§ μμ΅λλ€."}