-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: automatically create groups when creating project
- Loading branch information
1 parent
bb9029c
commit 892aeea
Showing
3 changed files
with
59 additions
and
5 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
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 |
---|---|---|
|
@@ -150,6 +150,54 @@ def test_toggle_locked_groups(self): | |
past_project.toggle_groups_locked() | ||
self.assertIs(past_project.locked_groups, False) | ||
|
||
def test_automatically_create_groups_when_creating_project(self): | ||
""" | ||
creating a project as a teacher should open the same amount of groups as students enrolled in the project. | ||
""" | ||
course = create_course(id=3, name="test course", academic_startyear=2024) | ||
|
||
student1 = create_student( | ||
id=1, first_name="John", last_name="Doe", email="[email protected]" | ||
) | ||
student2 = create_student( | ||
id=2, first_name="Jane", last_name="Doe", email="[email protected]" | ||
) | ||
student1.courses.add(course) | ||
student2.courses.add(course) | ||
|
||
project_data = { | ||
"name": "Test Project", | ||
"description": "Test project description", | ||
"visible": True, | ||
"archived": False, | ||
"start_date": timezone.now(), | ||
"deadline": timezone.now() + timezone.timedelta(days=1), | ||
} | ||
|
||
response = self.client.post( | ||
reverse("course-projects", args=[course.id]), data=project_data, follow=True | ||
) | ||
|
||
# Creating a group as a teacher should work | ||
self.assertEqual(response.status_code, 200) | ||
|
||
project = Project.objects.get( | ||
name="Test Project", | ||
description="Test project description", | ||
visible=True, | ||
archived=False, | ||
start_date=project_data["start_date"], | ||
deadline=project_data["deadline"], | ||
course=course, | ||
) | ||
|
||
groups_count = project.groups.count() | ||
# The amount of students participating in the corresponding course | ||
expected_groups_count = 2 | ||
|
||
# We expect the amount of groups to be the same as the amount of students in the course | ||
self.assertEqual(groups_count, expected_groups_count) | ||
|
||
def test_start_date_Project_not_in_past(self): | ||
""" | ||
unable to create a project as a teacher/admin if the start date lies within the past. | ||
|
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