Пример #1
0
    def test_leave_group_student_not_in_group(self):
        # Make a study group
        study_group = StudyGroup(name="banana", maxSize=4)
        study_group.save()

        # Add Student to group
        study_group.members.add(self.student1)
        study_group.save()

        # Obtain Group ID to pass as a parameter to the request
        group = StudyGroup.objects.get(name="banana")
        id = group.id

        # Make request and call leaveGroup
        request = self.request_factory.post(reverse('studygroups:leaveGroup'),
                                            {
                                                'Group': [str(id)],
                                                'edit': ['']
                                            })
        request.user = self.user
        leaveGroup(request)

        actual = study_group.get_members()
        expected = [self.student1]
        self.assertEqual(expected, actual)
Пример #2
0
    def test_get_members_empty(self):
        # Make a study group
        study_group = StudyGroup(
            name="banana",
            maxSize=4,
        )
        study_group.save()

        actual = study_group.get_members()
        expected = []

        self.assertEqual(expected, actual)
Пример #3
0
    def test_get_members_not_empty(self):
        # Make a study group
        study_group = StudyGroup(
            name="banana",
            maxSize=4,
        )
        study_group.save()

        # Add Student to group
        study_group.members.add(self.student)
        study_group.save()

        actual = study_group.get_members()
        expected = [self.student]

        self.assertEqual(expected, actual)