From 8730001c22a404349a0c57bd75a620149d24d7e4 Mon Sep 17 00:00:00 2001 From: Jarne Clauw <67628242+JarneClauw@users.noreply.github.com> Date: Fri, 5 Apr 2024 09:51:29 +0200 Subject: [PATCH] updating tests --- backend/tests/endpoints/course/courses_test.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/backend/tests/endpoints/course/courses_test.py b/backend/tests/endpoints/course/courses_test.py index 55f72d9b..2d1d623a 100644 --- a/backend/tests/endpoints/course/courses_test.py +++ b/backend/tests/endpoints/course/courses_test.py @@ -66,7 +66,7 @@ def test_get_courses_all(self, client: FlaskClient, courses: List[Course]): data = [course["name"] for course in response.json["data"]] assert all(course.name in data for course in courses) - def test_get_courses_wrong_parameter(self, client: FlaskClient): + def test_get_courses_wrong_argument(self, client: FlaskClient): """Test getting courses for a wrong parameter""" response = client.get("/courses?parameter=0", headers = {"Authorization": "student"}) assert response.status_code == 400 @@ -285,7 +285,7 @@ def test_patch_course_incorrect_field(self, client: FlaskClient, course: Course) response = client.patch( f"/courses/{course.course_id}", headers = {"Authorization": "teacher"}, - json = {"field": 0} + json = {"incorrect": 0} ) assert response.status_code == 400 @@ -386,7 +386,7 @@ def test_post_students_incorrect_field( assert response.status_code == 400 def test_post_students_correct( - self, client: FlaskClient, course: Course, student_other: User + self, client: FlaskClient, api_host: str, course: Course, student_other: User ): """Test adding students to a course""" response = client.post( @@ -397,8 +397,7 @@ def test_post_students_correct( } ) assert response.status_code == 201 - data = response.json["data"][0] - assert not data + assert response.json["data"]["students"][0] == f"{api_host}/users/student_other" @@ -584,7 +583,7 @@ def test_delete_admins_correct(self, client: FlaskClient, course: Course, admin: "admin_uid": admin.uid } ) - assert response.status_code == 200 + assert response.status_code == 204 response = client.get( f"/courses/{course.course_id}/admins", headers = {"Authorization": "teacher"}