예제 #1
0
    def test_same_user_key_in_multiple_organizations(self):
        uox_program_enrollment = self._create_waiting_program_enrollment()

        second_organization = OrganizationFactory.create()
        SAMLProviderConfigFactory.create(organization=second_organization, slug='aiu')
        catalog_org = CatalogOrganizationFactory.create(key=second_organization.short_name)
        program_uuid = self._create_catalog_program(catalog_org)['uuid']

        # aiu enrollment with the same student key as our uox user
        aiu_program_enrollment = ProgramEnrollmentFactory.create(
            user=None,
            external_user_key=self.external_id,
            program_uuid=program_uuid
        )

        UserSocialAuth.objects.create(
            user=UserFactory.create(),
            uid='{0}:{1}'.format('not_used', self.external_id),
        )

        UserSocialAuth.objects.create(
            user=self.user,
            uid='{0}:{1}'.format(self.provider_slug, self.external_id),
        )
        self._assert_program_enrollment_user(uox_program_enrollment, self.user)

        aiu_user = UserFactory.create()
        UserSocialAuth.objects.create(
            user=aiu_user,
            uid='{0}:{1}'.format('aiu', self.external_id),
        )
        self._assert_program_enrollment_user(aiu_program_enrollment, aiu_user)
예제 #2
0
    def setUp(self):
        super(TestCachePrograms, self).setUp()

        httpretty.httpretty.reset()

        self.catalog_integration = self.create_catalog_integration()
        self.site_domain = 'testsite.com'
        self.site = self.set_up_site(
            self.site_domain,
            {
                'COURSE_CATALOG_API_URL': self.catalog_integration.get_internal_api_url().rstrip('/')
            }
        )

        self.list_url = self.catalog_integration.get_internal_api_url().rstrip('/') + '/programs/'
        self.detail_tpl = self.list_url.rstrip('/') + '/{uuid}/'
        self.pathway_url = self.catalog_integration.get_internal_api_url().rstrip('/') + '/pathways/'

        self.programs = ProgramFactory.create_batch(3)
        self.pathways = PathwayFactory.create_batch(3)
        self.child_program = ProgramFactory.create()

        self.programs[0]['curricula'][0]['programs'].append(self.child_program)
        self.programs.append(self.child_program)

        self.programs[0]['authoring_organizations'] = OrganizationFactory.create_batch(2)

        for pathway in self.pathways:
            self.programs += pathway['programs']

        self.uuids = [program['uuid'] for program in self.programs]

        # add some of the previously created programs to some pathways
        self.pathways[0]['programs'].extend([self.programs[0], self.programs[1]])
        self.pathways[1]['programs'].append(self.programs[0])
예제 #3
0
    def test_same_user_key_in_multiple_organizations(self):
        uox_program_enrollment = self._create_waiting_program_enrollment()

        second_organization = OrganizationFactory.create()
        SAMLProviderConfigFactory.create(organization=second_organization,
                                         slug='aiu')
        catalog_org = CatalogOrganizationFactory.create(
            key=second_organization.short_name)
        program_uuid = self._create_catalog_program(catalog_org)['uuid']

        # aiu enrollment with the same student key as our uox user
        aiu_program_enrollment = ProgramEnrollmentFactory.create(
            user=None,
            external_user_key=self.external_id,
            program_uuid=program_uuid)

        UserSocialAuth.objects.create(
            user=UserFactory.create(),
            uid='{0}:{1}'.format('not_used', self.external_id),
        )

        UserSocialAuth.objects.create(
            user=self.user,
            uid='{0}:{1}'.format(self.provider_slug, self.external_id),
        )
        self._assert_program_enrollment_user(uox_program_enrollment, self.user)

        aiu_user = UserFactory.create()
        UserSocialAuth.objects.create(
            user=aiu_user,
            uid='{0}:{1}'.format('aiu', self.external_id),
        )
        self._assert_program_enrollment_user(aiu_program_enrollment, aiu_user)
예제 #4
0
 def setUp(self):
     super(GetUsersByExternalKeysTests, self).setUp()
     catalog_org = CatalogOrganizationFactory.create(key=self.organization_key)
     program = ProgramFactory.create(
         uuid=self.program_uuid,
         authoring_organizations=[catalog_org]
     )
     cache.set(PROGRAM_CACHE_KEY_TPL.format(uuid=self.program_uuid), program, None)
예제 #5
0
 def setup_catalog_cache(self, program_uuid, organization_key):
     """
     helper function to initialize a cached program with an single authoring_organization
     """
     catalog_org = CatalogOrganizationFactory.create(key=organization_key)
     program = ProgramFactory.create(uuid=program_uuid,
                                     authoring_organizations=[catalog_org])
     cache.set(PROGRAM_CACHE_KEY_TPL.format(uuid=program_uuid), program,
               None)
예제 #6
0
 def setup_catalog_cache(self, program_uuid, organization_key):
     """
     helper function to initialize a cached program with an single authoring_organization
     """
     catalog_org = CatalogOrganizationFactory.create(key=organization_key)
     program = ProgramFactory.create(
         uuid=program_uuid,
         authoring_organizations=[catalog_org]
     )
     cache.set(PROGRAM_CACHE_KEY_TPL.format(uuid=program_uuid), program, None)
예제 #7
0
 def setUp(self):
     """
     Set up test data
     """
     super(WritingProgramEnrollmentTest, self).setUp()
     catalog_org = CatalogOrganizationFactory.create(
         key=self.organization_key)
     program = ProgramFactory.create(uuid=self.program_uuid_x,
                                     authoring_organizations=[catalog_org])
     organization = OrganizationFactory.create(
         short_name=self.organization_key)
     SAMLProviderConfigFactory.create(organization=organization)
     cache.set(PROGRAM_CACHE_KEY_TPL.format(uuid=self.program_uuid_x),
               program, None)
예제 #8
0
    def setUpClass(cls):
        """
        Set up test data
        """
        super().setUpClass()
        catalog_org = CatalogOrganizationFactory.create(
            key=cls.organization_key)
        cls.program = ProgramFactory.create(
            uuid=cls.program_uuid, authoring_organizations=[catalog_org])
        organization = OrganizationFactory.create(
            short_name=cls.organization_key)
        SAMLProviderConfigFactory.create(organization=organization)

        catalog_course_id_str = 'course-v1:edX+ToyX'
        course_run_id_str = f'{catalog_course_id_str}+Toy_Course'
        cls.course_id = CourseKey.from_string(course_run_id_str)
        CourseOverviewFactory(id=cls.course_id)
        course_run = CourseRunFactory(key=course_run_id_str)
        cls.course = CourseFactory(key=catalog_course_id_str,
                                   course_runs=[course_run])
        cls.student_1 = UserFactory(username='******')
        cls.student_2 = UserFactory(username='******')
예제 #9
0
    def setUp(self):
        super(TestProgramDataExtender, self).setUp()

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

        self.course = ModuleStoreCourseFactory()
        self.course.start = datetime.datetime.now(utc) - datetime.timedelta(
            days=1)
        self.course.end = datetime.datetime.now(utc) + datetime.timedelta(
            days=1)
        self.course = self.update_course(self.course, self.user.id)  # pylint: disable=no-member

        organization = OrganizationFactory()
        course_run = CourseRunFactory(key=unicode(self.course.id))  # pylint: disable=no-member
        course = CourseFactory(course_runs=[course_run])
        program = ProgramFactory(authoring_organizations=[organization],
                                 courses=[course])

        self.program = munge_catalog_program(program)
        self.course_code = self.program['course_codes'][0]
        self.run_mode = self.course_code['run_modes'][0]
예제 #10
0
 def setUp(self):
     super(SocialAuthEnrollmentCompletionSignalTest, self).setUp()
     RequestCache.clear_all_namespaces()
     catalog_org = CatalogOrganizationFactory.create(key=self.organization.short_name)
     self.program_uuid = self._create_catalog_program(catalog_org)['uuid']
예제 #11
0
 def setUp(self):
     super(SocialAuthEnrollmentCompletionSignalTest, self).setUp()
     RequestCache.clear_all_namespaces()
     catalog_org = CatalogOrganizationFactory.create(
         key=self.organization.short_name)
     self.program_uuid = self._create_catalog_program(catalog_org)['uuid']
예제 #12
0
 def setUp(self):
     super().setUp()
     RequestCache.clear_all_namespaces()
     catalog_org = CatalogOrganizationFactory.create(
         key=self.organization.short_name)
     self.program_uuid = self._create_catalog_program(catalog_org)['uuid']