Feat: add put for student and fix fixture around database
This commit is contained in:
@@ -55,3 +55,24 @@ def test_api_post_student_in_non_existant_tribe():
|
||||
r.json()
|
||||
== f"The tribe {tribe.name+'_'} does not exists. You can't add a student in it."
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("restart_api")
|
||||
@pytest.mark.usefixtures("clean_db")
|
||||
def test_api_put_student():
|
||||
url = config.get_api_url()
|
||||
tribe = build_tribes(1)[0]
|
||||
requests.post(f"{url}/tribes", json=tribe.to_dict())
|
||||
|
||||
data = {"name": "zart", "tribe_name": tribe.name}
|
||||
r = requests.post(f"{url}/students", json=data)
|
||||
|
||||
student = r.json()
|
||||
student["name"] = "Choupinou"
|
||||
|
||||
r2 = requests.put(f"{url}/students/{student['id']}", json=student)
|
||||
|
||||
assert r2.status_code == 200
|
||||
assert r2.json()["name"] == "Choupinou"
|
||||
assert r2.json()["tribe_name"] == tribe.name
|
||||
assert r2.json()["id"] == r.json()["id"]
|
||||
|
||||
@@ -28,7 +28,7 @@ def test_api_post_tribe_already_exists():
|
||||
data = {"name": "Pioupiou", "level": "2nd"}
|
||||
|
||||
url = config.get_api_url()
|
||||
r = requests.post(f"{url}/tribes", json=data)
|
||||
requests.post(f"{url}/tribes", json=data)
|
||||
r = requests.post(f"{url}/tribes", json=data)
|
||||
|
||||
assert r.status_code == 409
|
||||
|
||||
Reference in New Issue
Block a user