Ejemplo n.º 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])
 def setUp(self):
     super().setUp()
     self.site = Site.objects.get(domain="example.com")
     new_course = CourseFactory.create(site=self.site)
     self.new_course_run = CourseRunFactory.create(course=new_course)
     self.orgs = [
         OrganizationFactory.create(name=name, site=self.site)
         for name in ["TestOrg1", "TestOrg2"]
     ]
Ejemplo n.º 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)
Ejemplo n.º 4
0
    def setUp(self):
        super().setUp()
        dump_random_state()

        self.user = UserFactory(username=self.MOCK_USER_DATA["username"])
        self.orgs = [OrganizationFactory.create(name=name, site=self.site) for name in ["TestOrg1", "TestOrg2"]]
        self.course = CourseFactory.create(site=self.site)
        self.course_runs = CourseRunFactory.create_batch(2, course=self.course)
        self.program = ProgramFactory(
            title="TestProgram1", course_runs=self.course_runs, authoring_organizations=self.orgs, site=self.site
        )
        self.course_certs = [
            CourseCertificateFactory.create(
                course_id=course_run.key,
                site=self.site,
            )
            for course_run in self.course_runs
        ]
        self.program_cert = ProgramCertificateFactory.create(program_uuid=self.program.uuid, site=self.site)
        self.course_credential_content_type = ContentType.objects.get(
            app_label="credentials", model="coursecertificate"
        )
        self.program_credential_content_type = ContentType.objects.get(
            app_label="credentials", model="programcertificate"
        )
        self.course_user_credentials = [
            UserCredentialFactory.create(
                username=self.user.username,
                credential_content_type=self.course_credential_content_type,
                credential=course_cert,
            )
            for course_cert in self.course_certs
        ]
        self.program_user_credential = UserCredentialFactory.create(
            username=self.user.username,
            credential_content_type=self.program_credential_content_type,
            credential=self.program_cert,
        )

        self.client.login(username=self.user.username, password=USER_PASSWORD)
Ejemplo n.º 5
0
    def test_keep_old_data(self):
        """ Verify that we don't destroy existing but obsolete data. """
        # org with a uuid that won't be in data we get back
        org = OrganizationFactory(site=self.site,
                                  uuid='44f0dded-fee9-4dec-a333-b9d8c2c82bd2',
                                  key='OldX')
        program = ProgramFactory(site=self.site,
                                 uuid='33f0dded-fee9-4dec-a333-c9d8c2c82bd5',
                                 title='Old Program')
        program.authoring_organizations.add(org)  # pylint: disable=no-member

        self.mock_access_token_response()
        self.mock_programs_response(self.wrap_programs(self.PROGRAMS))
        self.mock_pathways_response(self.wrap_pathways(self.PATHWAYS))
        self.call_command()

        org = Organization.objects.get(uuid='44f0dded-fee9-4dec-a333-b9d8c2c82bd2',
                                       key='OldX')

        # But note that it will no longer be connected to our program
        program = Program.objects.get(uuid='33f0dded-fee9-4dec-a333-c9d8c2c82bd5')
        self.assertNotIn(org, program.authoring_organizations.all())
Ejemplo n.º 6
0
    def test_update(self):
        """ Verify the command updates existing data. """
        OrganizationFactory(site=self.site,
                            uuid='33f0dded-fee9-4dec-a333-b9d8c2c82bd2',
                            key='OldX')
        ProgramFactory(site=self.site,
                       uuid='33f0dded-fee9-4dec-a333-c9d8c2c82bd5',
                       title='Old Program')

        self.mock_access_token_response()
        self.mock_programs_response(self.wrap_programs(self.PROGRAMS))
        self.mock_pathways_response(self.wrap_pathways(self.PATHWAYS))
        self.call_command()

        self.assertProgramsSaved()
        self.assertPathwaysSaved()

        org = Organization.objects.get(uuid='33f0dded-fee9-4dec-a333-b9d8c2c82bd2')
        self.assertNotEqual(org.key, 'OldX')

        program = Program.objects.get(uuid='33f0dded-fee9-4dec-a333-c9d8c2c82bd5')
        self.assertNotEqual(program.title, 'Old Program')
Ejemplo n.º 7
0
    def setUp(self):
        super().setUp()
        self.user = UserFactory(username=self.MOCK_USER_DATA['username'])
        self.orgs = [
            OrganizationFactory.create(name=name, site=self.site)
            for name in ['TestOrg1', 'TestOrg2']
        ]
        self.course = CourseFactory.create(site=self.site)
        self.course_runs = [
            CourseRunFactory.create(course=self.course) for _ in range(2)
        ]
        self.program = ProgramFactory(course_runs=self.course_runs,
                                      authoring_organizations=self.orgs,
                                      site=self.site)
        self.course_certs = [
            CourseCertificateFactory.create(
                course_id=course_run.key,
                site=self.site,
            ) for course_run in self.course_runs
        ]
        self.program_cert = ProgramCertificateFactory.create(
            program_uuid=self.program.uuid, site=self.site)
        self.course_credential_content_type = ContentType.objects.get(
            app_label='credentials', model='coursecertificate')
        self.program_credential_content_type = ContentType.objects.get(
            app_label='credentials', model='programcertificate')
        self.course_user_credentials = [
            UserCredentialFactory.create(
                username=self.user.username,
                credential_content_type=self.course_credential_content_type,
                credential=course_cert) for course_cert in self.course_certs
        ]
        self.program_user_credentials = UserCredentialFactory.create(
            username=self.user.username,
            credential_content_type=self.program_credential_content_type,
            credential=self.program_cert)

        self.client.login(username=self.user.username, password=USER_PASSWORD)