Skip to content

Commit

Permalink
Complete (#867)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmi4er4 authored Aug 19, 2024
1 parent b8a5231 commit c5446d8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion apps/learning/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def manage_student_group_for_course_root_branch(sender, instance, created,
@receiver(post_save, sender=CourseBranch)
def create_student_group_from_course_branch(sender, instance: CourseBranch,
created, *args, **kwargs):
if created and instance.course.group_mode == CourseGroupModes.BRANCH:
if created and instance.course.group_mode in [CourseGroupModes.BRANCH, CourseGroupModes.INVITE_AND_BRANCH]:
StudentGroupService.create(instance.course,
group_type=StudentGroupTypes.BRANCH,
branch=instance.branch)
Expand Down
5 changes: 3 additions & 2 deletions apps/learning/tests/test_student_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,12 @@ def test_create_student_group_from_main_branch(settings):


@pytest.mark.django_db
def test_upsert_student_group_from_additional_branch(settings):
@pytest.mark.parametrize("group_mode", [CourseGroupModes.BRANCH, CourseGroupModes.INVITE_AND_BRANCH])
def test_upsert_student_group_from_additional_branch(settings, group_mode):
branch_spb = BranchFactory(code=Branches.SPB)
branch_nsk = BranchFactory(code=Branches.NSK)
course = CourseFactory(main_branch=branch_spb,
group_mode=StudentGroupTypes.BRANCH)
group_mode=group_mode)
assert StudentGroup.objects.filter(course=course).count() == 1
CourseBranch(course=course, branch=branch_nsk).save()
groups = StudentGroup.objects.filter(course=course)
Expand Down

0 comments on commit c5446d8

Please sign in to comment.