Esempio n. 1
0
 def setUp(self):
     self.u1 = UniversityFactory.create(detail_page_enabled=True,
                                        is_obsolete=False,
                                        score=1)
     self.u2 = UniversityFactory.create(detail_page_enabled=True,
                                        is_obsolete=False,
                                        score=1)
Esempio n. 2
0
    def test_not_obsolete(self):
        u1 = UniversityFactory.create(detail_page_enabled=True, is_obsolete=False)
        u2 = UniversityFactory.create(detail_page_enabled=True, is_obsolete=True)

        not_obsolete = models.University.objects.not_obsolete()
        self.assertIn(u1, not_obsolete)
        self.assertNotIn(u2, not_obsolete)
Esempio n. 3
0
    def test_landing_view(self):
        u1 = UniversityFactory.create(detail_page_enabled=True, is_obsolete=False)
        u2 = UniversityFactory.create(detail_page_enabled=False, is_obsolete=False)
        u3 = UniversityFactory.create(detail_page_enabled=False, is_obsolete=True)
        u4 = UniversityFactory.create(detail_page_enabled=True, is_obsolete=True)

        listed_universities = list(views.UniversityLandingView().get_queryset())

        self.assertTrue(u1 in listed_universities)
        self.assertFalse(u2 in listed_universities)
        self.assertFalse(u3 in listed_universities)
        self.assertFalse(u4 in listed_universities)
Esempio n. 4
0
    def test_featured(self):
        u1 = UniversityFactory.create(detail_page_enabled=True, is_obsolete=False, score=1)
        u2 = UniversityFactory.create(detail_page_enabled=False, is_obsolete=False, score=2)
        u3 = UniversityFactory.create(detail_page_enabled=False, is_obsolete=True, score=3)
        u4 = UniversityFactory.create(detail_page_enabled=True, is_obsolete=True, score=4)

        featured_universities = list(models.University.objects.featured(4))

        self.assertTrue(u1 in featured_universities)
        self.assertFalse(u2 in featured_universities)
        self.assertFalse(u3 in featured_universities)
        self.assertFalse(u4 in featured_universities)
        self.assertEqual(1, len(featured_universities))
Esempio n. 5
0
 def configure_course(self):
     """
     Make sure that all the right course models exist for generating the certificate.
     """
     fun_course = FunCourseFactory(key=unicode(self.course.id))
     fun_university = UniversityFactory.create()
     CourseUniversityRelationFactory(course=fun_course, university=fun_university)
Esempio n. 6
0
 def configure_course(self):
     """
     Make sure that all the right course models exist for generating the certificate.
     """
     fun_course = FunCourseFactory(key=unicode(self.course.id))
     fun_university = UniversityFactory.create()
     CourseUniversityRelationFactory(course=fun_course, university=fun_university)
Esempio n. 7
0
    def setUp(self):
        super(BaseCourseList, self).setUp(create_user=False)
        self.user = User.objects.create(username='******', is_staff=True)
        self.user.set_password('password')
        self.user.save()
        self.backoffice_group, _created = Group.objects.get_or_create(
            name='fun_backoffice')
        self.user.groups.add(self.backoffice_group)
        UserProfile.objects.create(user=self.user)
        self.client.login(username=self.user.username, password='******')

        self.university = UniversityFactory.create()
        self.course1 = CourseFactory.create(number='001',
                                            display_name=u"unpublished",
                                            ispublic=False,
                                            org=self.university.code)

        CourseAboutFactory.create(course_id=self.course1.id,
                                  course_runtime=self.course1.runtime)

        self.course2 = CourseFactory.create(org=self.university.code,
                                            number='002',
                                            display_name=u"published",
                                            ispublic=True)
        self.list_url = reverse('backoffice:courses-list')
Esempio n. 8
0
    def init(self, is_superuser, university_code=None):
        self.backoffice_group, _created = Group.objects.get_or_create(name='fun_backoffice')
        self.user.is_staff = False
        self.user.is_superuser = is_superuser
        self.user.save()
        UserProfile.objects.create(user=self.user)
        self.course = CourseFactory.create(org=university_code)

        self.fun_course = FunCourseFactory.create(key=unicode(self.course.scope_ids.usage_id.course_key))
        if university_code:
            self.university = UniversityFactory.create(slug=university_code, code=university_code)
            CourseUniversityRelationFactory(course=self.fun_course, university=self.university)
Esempio n. 9
0
    def init(self, is_superuser, university_code=None):
        self.backoffice_group, _created = Group.objects.get_or_create(
            name='fun_backoffice')
        self.user.is_staff = False
        self.user.is_superuser = is_superuser
        self.user.save()
        UserProfile.objects.create(user=self.user)
        self.course = CourseFactory.create(org=university_code)

        self.fun_course = FunCourseFactory.create(
            key=unicode(self.course.scope_ids.usage_id.course_key))
        if university_code:
            self.university = UniversityFactory.create(slug=university_code,
                                                       code=university_code)
            CourseUniversityRelationFactory(course=self.fun_course,
                                            university=self.university)
Esempio n. 10
0
    def test_change_and_regenerate_grade(self):
        # Proper university and course objects need to be created in order to
        # generate the pdf files
        fun_course = FunCourseFactory(key=unicode(self.course1.id))
        fun_university = UniversityFactory.create()
        CourseUniversityRelationFactory(course=fun_course, university=fun_university)
        CourseEnrollmentFactory(course_id=self.course1.id, user=self.user2)

        generated_certificate = self._create_certificate(self.course1, 0.8)
        certificate = self._change_certificate_grade(generated_certificate, 0.9, self.user2, True)
        self.assertEqual(certificate.grade, '0.9')
        # GeneratedCertificateFactory do not create pdf certificate so download_url is blank,
        # call to _change_certificate_grade with regenerate=True create pdf and set download_url
        cert_url = certificate.download_url
        self.assertNotEqual(generated_certificate.download_url, cert_url)
        # Regenerate certificate, url should remain the same
        certificate = self._change_certificate_grade(generated_certificate, 0.99, self.user2, True)
        self.assertEqual(cert_url, certificate.download_url)
Esempio n. 11
0
    def setUp(self):
        super(BaseCourseList, self).setUp(create_user=False)
        self.user = User.objects.create(username='******', is_staff=True)
        self.user.set_password('password')
        self.user.save()
        self.backoffice_group, _created = Group.objects.get_or_create(name='fun_backoffice')
        self.user.groups.add(self.backoffice_group)
        UserProfile.objects.create(user=self.user)
        self.client.login(username=self.user.username, password='******')

        self.university = UniversityFactory.create()
        self.course1 = CourseFactory.create(number='001', display_name=u"unpublished",
                                            ispublic=False, org=self.university.code)

        CourseAboutFactory.create(course_id=self.course1.id,
                                  course_runtime=self.course1.runtime)

        self.course2 = CourseFactory.create(org=self.university.code, number='002',
                             display_name=u"published", ispublic=True)
        self.list_url = reverse('backoffice:courses-list')