You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
674 B
27 lines
674 B
import requests
|
|
import json
|
|
|
|
API_URL= "http://127.0.0.1:8000/api"
|
|
def test_get_student():
|
|
response = requests.get(f"{API_URL}/students")
|
|
assert response.status_code == 200
|
|
assert len(response.json()) == 1
|
|
print("成功获取")
|
|
def test_student_creation():
|
|
"""测试学生创建功能"""
|
|
student_data = {
|
|
"student_id": "2021001",
|
|
"name": "张三",
|
|
"major": "计算机科学"
|
|
}
|
|
response = requests.post(f"{API_URL}/students/", json=student_data)
|
|
assert response.status_code == 200
|
|
assert response.json()["name"] == "张三"
|
|
print("成功创建")
|
|
data = test_student_creation()
|
|
data = test_get_student()
|
|
|
|
|
|
|
|
|