This repository has been archived by the owner on Sep 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |