Exemple #1
0
    def setUp(self):
        super().setUp()
        dump_random_state()

        self.user = UserFactory(username=self.MOCK_USER_DATA["username"])
        self.client.login(username=self.user.username, password=USER_PASSWORD)

        self.course = CourseFactory(site=self.site)
        self.course_runs = CourseRunFactory.create_batch(3, course=self.course)

        self.user_grade_low = UserGradeFactory(
            username=self.MOCK_USER_DATA["username"],
            course_run=self.course_runs[0],
            letter_grade="A",
            percent_grade=0.70,
        )
        self.user_grade_high = UserGradeFactory(
            username=self.MOCK_USER_DATA["username"],
            course_run=self.course_runs[1],
            letter_grade="C",
            percent_grade=1.00,
        )
        self.user_grade_revoked_cert = UserGradeFactory(
            username=self.MOCK_USER_DATA["username"],
            course_run=self.course_runs[2],
            letter_grade="B",
            percent_grade=0.80,
        )

        self.course_certs = [
            CourseCertificateFactory(course_id=course_run.key, site=self.site) for course_run in self.course_runs
        ]
        self.credential_content_type = ContentType.objects.get(app_label="credentials", model="coursecertificate")
        self.program_cert = ProgramCertificateFactory(site=self.site)
        self.program_content_type = ContentType.objects.get(app_label="credentials", model="programcertificate")
        self.user_credentials = [
            UserCredentialFactory(
                username=self.MOCK_USER_DATA["username"],
                credential_content_type=self.credential_content_type,
                credential=course_cert,
            )
            for course_cert in self.course_certs
        ]
        self.user_credentials[2].status = UserCredential.REVOKED
        self.user_credentials[2].save()
        self.org_names = ["CCC", "AAA", "BBB"]
        self.orgs = [OrganizationFactory(name=name, site=self.site) for name in self.org_names]
        self.program = ProgramFactory(
            course_runs=self.course_runs,
            authoring_organizations=self.orgs,
            site=self.site,
            uuid=self.program_cert.program_uuid,
        )
        self.pcr = ProgramCertRecordFactory(program=self.program, user=self.user)

        self.pathway = PathwayFactory(site=self.site)
        self.pathway.programs.set([self.program])
Exemple #2
0
    def setUp(self):
        super().setUp()
        dump_random_state()
        self.user = UserFactory(username=self.USERNAME)
        self.client.login(username=self.user.username, password=USER_PASSWORD)
        self.program = ProgramFactory(site=self.site)
        self.pathway = PathwayFactory(site=self.site, programs=[self.program])
        self.pc = ProgramCertificateFactory(site=self.site, program_uuid=self.program.uuid)
        self.pcr = ProgramCertRecordFactory(program=self.program, user=self.user)
        self.data = {'username': self.USERNAME, 'pathway_id': self.pathway.id}
        self.url = reverse('records:share_program', kwargs={'uuid': self.program.uuid.hex})

        mail.outbox = []
Exemple #3
0
 def setUp(self):
     super().setUp()
     self.user = UserFactory(username=self.MOCK_USER_DATA['username'])
     self.client.login(username=self.user.username, password=USER_PASSWORD)
     self.course = CourseFactory(site=self.site)
     self.course_runs = [CourseRunFactory(course=self.course) for _ in range(3)]
     self.user_grade_low = UserGradeFactory(username=self.MOCK_USER_DATA['username'],
                                            course_run=self.course_runs[0], letter_grade='A', percent_grade=0.70)
     self.user_grade_high = UserGradeFactory(username=self.MOCK_USER_DATA['username'],
                                             course_run=self.course_runs[1], letter_grade='C', percent_grade=1.00)
     self.user_grade_revoked_cert = UserGradeFactory(username=self.MOCK_USER_DATA['username'],
                                                     course_run=self.course_runs[2], letter_grade='B',
                                                     percent_grade=.80)
     self.course_certs = [CourseCertificateFactory(course_id=course_run.key, site=self.site)
                          for course_run in self.course_runs]
     self.credential_content_type = ContentType.objects.get(app_label='credentials', model='coursecertificate')
     self.user_credentials = [UserCredentialFactory(username=self.MOCK_USER_DATA['username'],
                              credential_content_type=self.credential_content_type, credential=course_cert)
                              for course_cert in self.course_certs]
     self.user_credentials[2].status = UserCredential.REVOKED
     self.org_names = ['CCC', 'AAA', 'BBB']
     self.orgs = [OrganizationFactory(name=name, site=self.site) for name in self.org_names]
     self.program = ProgramFactory(course_runs=self.course_runs, authoring_organizations=self.orgs, site=self.site)
     self.program_cert_record = ProgramCertRecordFactory.create(user=self.user, program=self.program)
Exemple #4
0
 def test_protected_deletion(self):
     program = ProgramFactory()
     ProgramCertRecordFactory(program=program)
     with self.assertRaises(ProtectedError):
         program.delete()