diff --git a/tests/e2e/test_api.py b/tests/e2e/test_api_students.py similarity index 57% rename from tests/e2e/test_api.py rename to tests/e2e/test_api_students.py index 99922c4..e05de00 100644 --- a/tests/e2e/test_api.py +++ b/tests/e2e/test_api_students.py @@ -5,57 +5,6 @@ from backend import config from tests.model.fakes import build_tribes -@pytest.mark.usefixtures("restart_api") -@pytest.mark.usefixtures("clean_db") -def test_api_post_tribe(): - data = {"name": "tribe", "level": "2nd"} - - url = config.get_api_url() - r = requests.post(f"{url}/tribes", json=data) - - assert r.status_code == 201 - assert r.json() == { - "assessments": [], - "level": "2nd", - "name": "tribe", - "students": [], - } - - -@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(): - tribe = build_tribes(1)[0] - - url = config.get_api_url() - r = requests.post(f"{url}/tribes", json=tribe.to_dict()) - - assert r.status_code == 201 - - r = requests.get(f"{url}/tribes") - assert r.json() == [ - { - "assessments": [], - "level": tribe.level, - "name": tribe.name, - "students": [], - } - ] - - @pytest.mark.usefixtures("restart_api") @pytest.mark.usefixtures("clean_db") def test_api_post_student(): diff --git a/tests/e2e/test_api_tribes.py b/tests/e2e/test_api_tribes.py new file mode 100644 index 0000000..a5b529b --- /dev/null +++ b/tests/e2e/test_api_tribes.py @@ -0,0 +1,56 @@ +import pytest +import requests + +from backend import config +from tests.model.fakes import build_tribes + + +@pytest.mark.usefixtures("restart_api") +@pytest.mark.usefixtures("clean_db") +def test_api_post_tribe(): + data = {"name": "tribe", "level": "2nd"} + + url = config.get_api_url() + r = requests.post(f"{url}/tribes", json=data) + + assert r.status_code == 201 + assert r.json() == { + "assessments": [], + "level": "2nd", + "name": "tribe", + "students": [], + } + + +@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(): + tribe = build_tribes(1)[0] + + url = config.get_api_url() + r = requests.post(f"{url}/tribes", json=tribe.to_dict()) + + assert r.status_code == 201 + + r = requests.get(f"{url}/tribes") + assert r.json() == [ + { + "assessments": [], + "level": tribe.level, + "name": tribe.name, + "students": [], + } + ]