Пример #1
0
    def setUp(self):
        self.view = RegistrationView()
        self.existing_user = UserFactory()
        self.client = Client()

        self.country = CountryFactory(name='LS')
        self.school = SchoolFactory(country=self.country)
Пример #2
0
    def setUp(self):
        self.teacher = TeacherProfileFactory().user
        self.school = SchoolFactory()
        self.client = Client()

        ModuleFactory("main", "/pages/main/")
        self.hierarchy = Hierarchy.objects.get(name='main')
Пример #3
0
 def setUp(self):
     self.user = UserFactory()
     self.up = UserProfileFactory(user=self.user)
     self.client = Client()
     self.client.login(username=self.user.username, password="******")
     self.country = CountryFactory()
     self.school = SchoolFactory()
Пример #4
0
 def test_get_no_groups(self):
     school = SchoolFactory()
     response = self.client.post('/groups/%s/' % school.id,
                                 {},
                                 HTTP_X_REQUESTED_WITH='XMLHttpRequest')
     self.assertEquals(response.status_code, 200)
     the_json = json.loads(response.content)
     self.assertEquals(len(the_json['groups']), 0)
Пример #5
0
    def setUp(self):
        ModuleFactory("main", "/pages/main/")
        self.hierarchy = Hierarchy.objects.get(name='main')
        self.section = self.hierarchy.get_root().get_first_leaf()

        self.school = SchoolFactory()
        self.country = self.school.country
        self.alt_school = SchoolFactory(country=self.country)

        self.teacher = TeacherProfileFactory(school=self.school).user
        self.iadmin = InstitutionAdminProfileFactory(
            school=self.alt_school).user
        self.admin = CountryAdministratorProfileFactory(
            country=self.country).user

        self.client = Client()
        self.client.login(username=self.admin.username, password="******")
Пример #6
0
    def test_unicode(self):
        school = SchoolFactory()
        student = StudentProfileFactory()
        teacher = PendingTeachers.objects.create(user_profile=student,
                                                 school=school)

        label = "%s - %s" % (student, school)
        self.assertEquals(label, teacher.__unicode__())
Пример #7
0
    def setUp(self):
        self.school = SchoolFactory()
        self.icap = ICAPProfileFactory().user
        self.teacher = TeacherProfileFactory().user
        self.pending = StudentProfileFactory().user

        PendingTeachers.objects.create(user_profile=self.pending.profile,
                                       school=self.school)

        self.client = Client()
Пример #8
0
    def setUp(self):
        self.country = CountryFactory()
        self.school = SchoolFactory(country=self.country)
        self.affiliated_student = StudentProfileFactory(country=self.country)
        self.affiliated_teacher = TeacherProfileFactory(school=self.school,
                                                        country=self.country)
        self.random_student = StudentProfileFactory()
        self.icap = ICAPProfileFactory(school=self.school,
                                       country=self.country)

        self.client = Client()
        self.client.login(username=self.icap.user.username, password="******")
Пример #9
0
    def test_managed_groups(self):
        teacher = TeacherProfileFactory().user
        teacher_grp = SchoolGroupFactory(creator=teacher)

        alt_teacher = TeacherProfileFactory().user  # test noise
        alt_teacher_grp = SchoolGroupFactory(creator=alt_teacher,
                                             school=teacher_grp.school)

        school = InstitutionAdminProfileFactory(
            country=teacher_grp.school.country, school=teacher_grp.school).user
        school_grp = SchoolGroupFactory(creator=school,
                                        school=teacher_grp.school)

        country = CountryAdministratorProfileFactory(
            country=teacher_grp.school.country).user
        country_school = SchoolFactory(country=teacher_grp.school.country)
        country_grp = SchoolGroupFactory(creator=country,
                                         school=country_school)

        icap = ICAPProfileFactory().user
        icap_grp = SchoolGroupFactory()

        groups = self.student.profile.get_managed_groups()
        self.assertEquals(groups.count(), 0)

        groups = teacher.profile.get_managed_groups()
        self.assertEquals(groups[0], teacher_grp)

        groups = school.profile.get_managed_groups()
        self.assertEquals(groups.count(), 3)
        self.assertTrue(alt_teacher_grp in groups)
        self.assertTrue(teacher_grp in groups)
        self.assertTrue(school_grp in groups)

        groups = country.profile.get_managed_groups()
        self.assertEquals(groups.count(), 4)
        self.assertTrue(alt_teacher_grp in groups)
        self.assertTrue(teacher_grp in groups)
        self.assertTrue(school_grp in groups)
        self.assertTrue(country_grp in groups)

        groups = icap.profile.get_managed_groups()
        self.assertEquals(groups.count(), 5)
        self.assertTrue(alt_teacher_grp in groups)
        self.assertTrue(teacher_grp in groups)
        self.assertTrue(school_grp in groups)
        self.assertTrue(country_grp in groups)
        self.assertTrue(icap_grp in groups)
Пример #10
0
    def test_get_visible_groups(self):
        school = SchoolFactory()
        joined = SchoolGroupFactory(school=school)
        joined.userprofile_set.add(self.user.profile)
        SchoolGroupFactory(archived=True, school=school)  # archived
        SchoolGroupFactory(creator=self.user, school=school)  # created

        grp = SchoolGroupFactory(school=school)

        response = self.client.post('/groups/%s/' % school.id,
                                    {},
                                    HTTP_X_REQUESTED_WITH='XMLHttpRequest')
        self.assertEquals(response.status_code, 200)
        the_json = json.loads(response.content)
        self.assertEquals(len(the_json['groups']), 1)

        self.assertEquals(the_json['groups'][0]['id'], str(grp.id))
        self.assertEquals(the_json['groups'][0]['name'], grp.name)
Пример #11
0
    def test_dashboard_context(self):
        request = RequestFactory().get('/dashboard/')
        request.user = self.admin

        admin_group = SchoolGroupFactory(creator=self.admin,
                                         school=self.admin.profile.school)
        teacher_group = SchoolGroupFactory(creator=self.teacher,
                                           school=self.teacher.profile.school)

        # archived groups
        SchoolGroupFactory(creator=self.teacher,
                           school=self.teacher.profile.school,
                           archived=True)
        SchoolGroupFactory(creator=self.admin,
                           school=self.admin.profile.school,
                           archived=True)

        # alt_creator/alt school
        SchoolGroupFactory(creator=TeacherProfileFactory().user)

        view = UserProfileView()
        view.request = request

        self.assertEquals(view.get_object(), request.user.profile)

        view.object = request.user.profile
        ctx = view.get_context_data()

        self.assertEquals(ctx['optionb'], self.hierarchy)
        self.assertIsNotNone(ctx['profile_form'])
        self.assertEquals(ctx['countries'], Country.choices())
        self.assertEquals(ctx['joined_groups'].count(), 0)
        self.assertEquals(len(ctx['managed_groups']), 2)
        self.assertEquals(ctx['managed_groups'][0], admin_group)
        self.assertEquals(ctx['managed_groups'][1], teacher_group)

        # pending teachers
        PendingTeacherFactory()  # random country/school
        alt_school = SchoolFactory(country=self.admin.profile.country)
        PendingTeacherFactory(school=alt_school)  # same country, diff school
        pt = PendingTeacherFactory(school=self.admin.profile.school)  # visible
        self.assertEquals(len(ctx['pending_teachers']), 1)
        self.assertEquals(ctx['pending_teachers'][0], pt)
Пример #12
0
 def setUp(self):
     self.country = CountryFactory()
     self.school = SchoolFactory()
     self.student = StudentProfileFactory().user