Feat: add response error when tribe already exists

This commit is contained in:
2022-12-29 07:23:02 +01:00
parent ccf1655cf4
commit febe686688
3 changed files with 51 additions and 2 deletions

View File

@@ -22,6 +22,19 @@ def test_api_post_tribe():
}
@pytest.mark.usefixtures("restart_api")
@pytest.mark.usefixtures("clean_db")
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)
r = requests.post(f"{url}/tribes", json=data)
assert r.status_code == 409
assert r.json() == f"The tribe {data['name']} already exists"
@pytest.mark.usefixtures("restart_api")
@pytest.mark.usefixtures("clean_db")
def test_api_post_list_tribe():
@@ -57,3 +70,19 @@ def test_api_post_student():
assert r.json()["name"] == "zart"
assert r.json()["tribe_name"] == tribe.name
assert r.json()["id"]
@pytest.mark.usefixtures("restart_api")
@pytest.mark.usefixtures("clean_db")
def test_api_post_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)
assert r.status_code == 201
assert r.json()["name"] == "zart"
assert r.json()["tribe_name"] == tribe.name
assert r.json()["id"]