Skip to content

Commit

Permalink
pytests fixed, 1 warning left
Browse files Browse the repository at this point in the history
  • Loading branch information
JibrilExe committed Feb 23, 2024
1 parent b162def commit f91ce9d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion backend/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ flask
flask-restful
flask-sqlalchemy
python-dotenv
psycopg2-binary
psycopg2-binary
1 change: 0 additions & 1 deletion backend/tests/models/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
11 changes: 6 additions & 5 deletions backend/tests/models/course_test.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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()
Expand Down Expand Up @@ -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()
Expand All @@ -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()

Expand All @@ -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()

Expand Down
4 changes: 2 additions & 2 deletions backend/tests/models/projects_and_submissions_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit f91ce9d

Please sign in to comment.