diff --git a/backend/requirements.txt b/backend/requirements.txt index f5118a9a..943fb75a 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -2,4 +2,4 @@ flask flask-restful flask-sqlalchemy python-dotenv -psycopg2-binary +psycopg2-binary \ No newline at end of file diff --git a/backend/tests/models/conftest.py b/backend/tests/models/conftest.py index f1156863..64e4461c 100644 --- a/backend/tests/models/conftest.py +++ b/backend/tests/models/conftest.py @@ -98,7 +98,6 @@ def valid_project(course): title="Project", descriptions="Test project", deadline=deadline, - course_id=course.course_id, visible_for_students=True, archieved=False, ) diff --git a/backend/tests/models/course_test.py b/backend/tests/models/course_test.py index 159bc86a..039f024f 100644 --- a/backend/tests/models/course_test.py +++ b/backend/tests/models/course_test.py @@ -1,5 +1,6 @@ import pytest from sqlalchemy.exc import IntegrityError +from psycopg2.errors import ForeignKeyViolation from project.models.courses import Courses from project.models.users import Users from project.models.course_relations import CourseAdmins, CourseStudents @@ -11,8 +12,7 @@ class TestCoursesModel: def test_foreignkey_courses_teacher(self, db_session, course: Courses): """Tests the foreign key relation between courses and the teacher uid""" with pytest.raises( - IntegrityError, - match="Courses should throw a foreign key error on the teacher uid", + IntegrityError ): db_session.add(course) db_session.commit() @@ -40,8 +40,7 @@ def test_foreignkey_coursestudents_uid( db_session.commit() with pytest.raises( - IntegrityError, - match="Course_relations should throw a foreign key error on the student uid", + IntegrityError ): db_session.add_all(course_students_relation) db_session.commit() @@ -66,6 +65,8 @@ def test_correct_courserelations( db_session.add_all(course_students) db_session.commit() + for s in course_students_relation: + s.course_id = course.course_id db_session.add_all(course_students_relation) db_session.commit() @@ -80,7 +81,7 @@ def test_correct_courserelations( db_session.add(assistent) db_session.commit() - + course_admin.course_id = course.course_id db_session.add(course_admin) db_session.commit() diff --git a/backend/tests/models/projects_and_submissions_test.py b/backend/tests/models/projects_and_submissions_test.py index 1cbaa0ae..e79eaf93 100644 --- a/backend/tests/models/projects_and_submissions_test.py +++ b/backend/tests/models/projects_and_submissions_test.py @@ -13,6 +13,7 @@ def test_deadline(self,db_session,course,course_teacher,valid_project,valid_user db_session.commit() db_session.add(course) db_session.commit() + valid_project.course_id = course.course_id db_session.add(valid_project) db_session.commit() check_project = ( @@ -40,8 +41,7 @@ def test_deadline(self,db_session,course,course_teacher,valid_project,valid_user assert submission_check.uid == valid_user.uid with pytest.raises( - IntegrityError, - match="Submissions model should throw an error on grades out of [0,20] range", + IntegrityError ): submission_check.grading = 100 db_session.commit()