Skip to content
This repository has been archived by the owner on Sep 27, 2024. It is now read-only.

Commit

Permalink
tests edge cases #58
Browse files Browse the repository at this point in the history
  • Loading branch information
lbarraga committed Mar 13, 2024
1 parent 255da1d commit 9300a98
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions backend/tests/test_edge_cases.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# test_edge_cases.py
import unittest
from datetime import datetime

from test_main import SessionLocal, test_engine

from db.errors.database_errors import ItemNotFoundError
from db.extensions import Base
from domain.logic import group, student, submission
from domain.models.SubmissionDataclass import SubmissionState


class TestEdgeCases(unittest.TestCase):
def setUp(self) -> None:
Base.metadata.drop_all(test_engine)
Base.metadata.create_all(test_engine)
self.session = SessionLocal()

def tearDown(self) -> None:
self.session.rollback()
self.session.close()

def test_add_student_to_non_existent_group(self) -> None:
stud = student.create_student(self.session, "Test Student", "[email protected]")
with self.assertRaises(ItemNotFoundError):
group.add_student_to_group(self.session, stud.id, 999)

def test_create_submission_for_non_existent_project(self) -> None:
stud = student.create_student(self.session, "Test Student", "[email protected]")
with self.assertRaises(ItemNotFoundError):
submission.create_submission(self.session, stud.id, 999, "Test Message", SubmissionState.Pending,
datetime.now())


if __name__ == "__main__":
unittest.main()

0 comments on commit 9300a98

Please sign in to comment.