Ejemplo n.º 1
0
 def setUp(self):
     self.user = factories.UserFactory(username='******',
                                       id=1,
                                       email='*****@*****.**')
     self.course_id = 'course-v1:edX+DemoX+DemoCourse'
     self.enterprise_customer = factories.EnterpriseCustomerFactory()
     self.enterprise_customer_user = factories.EnterpriseCustomerUserFactory(
         user_id=self.user.id,
         enterprise_customer=self.enterprise_customer,
     )
     self.data_sharing_consent = factories.DataSharingConsentFactory(
         username=self.user.username,
         course_id=self.course_id,
         enterprise_customer=self.enterprise_customer,
         granted=True,
     )
     self.config = factories.DegreedEnterpriseCustomerConfigurationFactory(
         enterprise_customer=self.enterprise_customer,
         active=True,
     )
     self.idp = factories.EnterpriseCustomerIdentityProviderFactory(
         enterprise_customer=self.enterprise_customer)
     tpa_client_mock = mock.patch(
         'enterprise.models.ThirdPartyAuthApiClient')
     self.tpa_client = tpa_client_mock.start()
     self.tpa_client.return_value.get_remote_id.return_value = 'fake-remote-id'
     self.addCleanup(tpa_client_mock.stop)
     super(TestDegreedLearnerExporter, self).setUp()
Ejemplo n.º 2
0
 def setUp(self):
     super().setUp()
     self.url_base = "http://betatest.degreed.com/"
     self.oauth_api_path = "oauth/token"
     self.oauth_url = urljoin(self.url_base, self.oauth_api_path)
     self.completion_status_api_path = "api/v1/provider/completion/course"
     self.completion_status_url = urljoin(self.url_base,
                                          self.completion_status_api_path)
     self.course_api_path = "api/v1/provider/content/course"
     self.course_url = urljoin(self.url_base, self.course_api_path)
     self.client_id = "client_id"
     self.client_secret = "client_secret"
     self.company_id = "company_id"
     self.user_id = "user_id"
     self.user_pass = "******"
     self.expires_in = 1800
     self.access_token = "access_token"
     self.expected_token_response_body = {
         "expires_in": self.expires_in,
         "access_token": self.access_token
     }
     factories.DegreedGlobalConfigurationFactory(
         completion_status_api_path=self.completion_status_api_path,
         course_api_path=self.course_api_path,
         oauth_api_path=self.oauth_api_path,
     )
     self.enterprise_config = factories.DegreedEnterpriseCustomerConfigurationFactory(
         key=self.client_id,
         secret=self.client_secret,
         degreed_company_id=self.company_id,
         degreed_base_url=self.url_base,
         degreed_user_id=self.user_id,
         degreed_user_password=self.user_pass,
     )
Ejemplo n.º 3
0
 def setUp(self):
     self.user = factories.UserFactory(username='******')
     self.enterprise_customer = factories.EnterpriseCustomerFactory(
         catalog=1,
         name='Veridian Dynamics',
     )
     self.degreed = factories.DegreedEnterpriseCustomerConfigurationFactory(
         enterprise_customer=self.enterprise_customer,
         key='key',
         secret='secret',
         degreed_company_id='Degreed Company',
         degreed_base_url='https://www.degreed.com/',
     )
     self.sapsf = factories.SAPSuccessFactorsEnterpriseCustomerConfigurationFactory(
         enterprise_customer=self.enterprise_customer,
         sapsf_base_url='http://enterprise.successfactors.com/',
         key='key',
         secret='secret',
         active=True,
     )
     self.sapsf_global_configuration = factories.SAPSuccessFactorsGlobalConfigurationFactory(
     )
     self.catalog_api_config_mock = self._make_patch(
         self._make_catalog_api_location("CatalogIntegration"))
     super(TestTransmitCourseMetadataManagementCommand, self).setUp()
Ejemplo n.º 4
0
 def setUp(self):
     self.api_user = factories.UserFactory(username='******', id=1)
     self.user1 = factories.UserFactory(id=2, email='*****@*****.**')
     self.user2 = factories.UserFactory(id=3, email='*****@*****.**')
     self.course_id = COURSE_ID
     self.enterprise_customer = factories.EnterpriseCustomerFactory(
         name='Spaghetti Enterprise')
     self.identity_provider = FakerFactory.create().slug()  # pylint: disable=no-member
     factories.EnterpriseCustomerIdentityProviderFactory(
         provider_id=self.identity_provider,
         enterprise_customer=self.enterprise_customer,
     )
     self.enterprise_customer_user1 = factories.EnterpriseCustomerUserFactory(
         user_id=self.user1.id,
         enterprise_customer=self.enterprise_customer,
     )
     self.enterprise_customer_user2 = factories.EnterpriseCustomerUserFactory(
         user_id=self.user2.id,
         enterprise_customer=self.enterprise_customer,
     )
     self.enrollment = factories.EnterpriseCourseEnrollmentFactory(
         id=2,
         enterprise_customer_user=self.enterprise_customer_user1,
         course_id=self.course_id,
     )
     self.enrollment = factories.EnterpriseCourseEnrollmentFactory(
         id=3,
         enterprise_customer_user=self.enterprise_customer_user2,
         course_id=self.course_id,
     )
     self.consent1 = factories.DataSharingConsentFactory(
         username=self.user1.username,
         course_id=self.course_id,
         enterprise_customer=self.enterprise_customer,
     )
     self.consent2 = factories.DataSharingConsentFactory(
         username=self.user2.username,
         course_id=self.course_id,
         enterprise_customer=self.enterprise_customer,
     )
     self.degreed = factories.DegreedEnterpriseCustomerConfigurationFactory(
         enterprise_customer=self.enterprise_customer,
         key='key',
         secret='secret',
         degreed_company_id='Degreed Company',
         active=True,
         degreed_base_url='https://www.degreed.com/',
     )
     self.degreed_global_configuration = factories.DegreedGlobalConfigurationFactory(
         oauth_api_path='oauth/token', )
     self.sapsf = factories.SAPSuccessFactorsEnterpriseCustomerConfigurationFactory(
         enterprise_customer=self.enterprise_customer,
         sapsf_base_url='http://enterprise.successfactors.com/',
         key='key',
         secret='secret',
         active=True,
     )
     self.sapsf_global_configuration = factories.SAPSuccessFactorsGlobalConfigurationFactory(
     )
     super(TestTransmitLearnerData, self).setUp()
    def setUp(self):
        self.enterprise_customer_catalog = factories.EnterpriseCustomerCatalogFactory()

        # Need a non-abstract config.
        self.config = factories.DegreedEnterpriseCustomerConfigurationFactory(
            enterprise_customer=self.enterprise_customer_catalog.enterprise_customer,
        )

        # Mocks
        self.mock_enterprise_customer_catalogs(str(self.enterprise_customer_catalog.uuid))
        jwt_builder = mock.patch('enterprise.api_client.lms.JwtBuilder', mock.Mock())
        self.jwt_builder = jwt_builder.start()
        self.addCleanup(jwt_builder.stop)
        super().setUp()
    def setUp(self):
        self.enterprise_customer_catalog = factories.EnterpriseCustomerCatalogFactory()

        # Need a non-abstract config.
        self.config = factories.DegreedEnterpriseCustomerConfigurationFactory(
            enterprise_customer=self.enterprise_customer_catalog.enterprise_customer,
        )

        # Mocks
        self.mock_ent_courses_api_with_pagination(
            str(self.enterprise_customer_catalog.enterprise_customer.uuid),
            ['course-v1:edX+DemoX+Demo_Course']
        )
        self.mock_enterprise_customer_catalogs(str(self.enterprise_customer_catalog.uuid))
        jwt_builder = mock.patch('enterprise.api_client.lms.JwtBuilder', mock.Mock())
        self.jwt_builder = jwt_builder.start()
        self.addCleanup(jwt_builder.stop)
        super(TestDegreedContentMetadataExporter, self).setUp()
Ejemplo n.º 7
0
    def test_transmit_content_metadata_task_with_error(
        self,
        sapsf_update_content_metadata_mock,
        sapsf_get_oauth_access_token_mock,
        degreed_create_content_metadata_mock,
    ):  # pylint: disable=invalid-name
        """
        Verify the data transmission task for integrated channels with error.

        Test that the management command `transmit_content_metadata` transmits
        courses metadata related to other integrated channels even if an
        integrated channel fails to transmit due to some error.
        """
        sapsf_get_oauth_access_token_mock.return_value = "token", datetime.utcnow(
        )
        sapsf_update_content_metadata_mock.return_value = 200, '{}'
        degreed_create_content_metadata_mock.return_value = 200, '{}'

        # Mock first integrated channel with failure
        enterprise_uuid_for_failure = str(self.enterprise_customer.uuid)
        self.mock_ent_courses_api_with_error(
            enterprise_uuid=enterprise_uuid_for_failure)

        # Now create a new integrated channel with a new enterprise and mock
        # enterprise courses API to send failure response
        course_run_id_for_success = 'course-v1:edX+DemoX+Demo_Course_1'
        dummy_enterprise_customer = factories.EnterpriseCustomerFactory(
            catalog=1,
            name='Dummy Enterprise',
        )
        dummy_degreed = factories.DegreedEnterpriseCustomerConfigurationFactory(
            enterprise_customer=dummy_enterprise_customer,
            key='key',
            secret='secret',
            degreed_company_id='Degreed Company',
            degreed_base_url='https://www.degreed.com/',
            active=True,
        )
        dummy_sapsf = factories.SAPSuccessFactorsEnterpriseCustomerConfigurationFactory(
            enterprise_customer=dummy_enterprise_customer,
            sapsf_base_url='http://enterprise.successfactors.com/',
            key='key',
            secret='secret',
            active=True,
        )

        enterprise_uuid_for_success = str(dummy_enterprise_customer.uuid)
        self.mock_ent_courses_api_with_pagination(
            enterprise_uuid=enterprise_uuid_for_success,
            course_run_ids=[course_run_id_for_success])

        # Verify that first integrated channel logs failure but the second
        # integrated channel still successfully transmits courseware data.
        expected_messages = [
            # SAPSF
            'Transmitting content metadata to integrated channel using configuration: '
            '[<SAPSuccessFactorsEnterpriseCustomerConfiguration for Enterprise Veridian Dynamics>]',
            'Transmission of content metadata failed for user [C-3PO] and for integrated channel with '
            'code [SAP] and id [1].',
            'Content metadata transmission task for integrated channel configuration [{}] took [0.0] seconds'
            .format(self.sapsf),
            'Transmitting content metadata to integrated channel using configuration: '
            '[<SAPSuccessFactorsEnterpriseCustomerConfiguration for Enterprise Dummy Enterprise>]',
            'Retrieved content metadata for enterprise [{}]'.format(
                dummy_enterprise_customer.name),
            'Exporting content metadata item with plugin configuration '
            '[<SAPSuccessFactorsEnterpriseCustomerConfiguration for Enterprise Dummy Enterprise>]',
            'Preparing to transmit creation of [1] content metadata items with plugin configuration '
            '[<SAPSuccessFactorsEnterpriseCustomerConfiguration for Enterprise Dummy Enterprise>]',
            'Preparing to transmit update of [0] content metadata items with plugin configuration '
            '[<SAPSuccessFactorsEnterpriseCustomerConfiguration for Enterprise Dummy Enterprise>]',
            'Preparing to transmit deletion of [0] content metadata items with plugin configuration '
            '[<SAPSuccessFactorsEnterpriseCustomerConfiguration for Enterprise Dummy Enterprise>]',
            'Content metadata transmission task for integrated channel configuration [{}] took [0.0] seconds'
            .format(dummy_sapsf),

            # Degreed
            'Transmitting content metadata to integrated channel using configuration: '
            '[<DegreedEnterpriseCustomerConfiguration for Enterprise Veridian Dynamics>]',
            'Transmission of content metadata failed for user [C-3PO] and for integrated channel with '
            'code [DEGREED] and id [1].',
            'Content metadata transmission task for integrated channel configuration [{}] took [0.0] seconds'
            .format(self.degreed),
            'Transmitting content metadata to integrated channel using configuration: '
            '[<DegreedEnterpriseCustomerConfiguration for Enterprise Dummy Enterprise>]',
            'Retrieved content metadata for enterprise [{}]'.format(
                dummy_enterprise_customer.name),
            'Exporting content metadata item with plugin configuration '
            '[<DegreedEnterpriseCustomerConfiguration for Enterprise Dummy Enterprise>]',
            'Preparing to transmit creation of [1] content metadata items with plugin configuration '
            '[<DegreedEnterpriseCustomerConfiguration for Enterprise Dummy Enterprise>]',
            'Preparing to transmit update of [0] content metadata items with plugin configuration '
            '[<DegreedEnterpriseCustomerConfiguration for Enterprise Dummy Enterprise>]',
            'Preparing to transmit deletion of [0] content metadata items with plugin configuration '
            '[<DegreedEnterpriseCustomerConfiguration for Enterprise Dummy Enterprise>]',
            'Content metadata transmission task for integrated channel configuration [{}] took [0.0] seconds'
            .format(dummy_degreed)
        ]

        with LogCapture(level=logging.INFO) as log_capture:
            call_command('transmit_content_metadata', '--catalog_user',
                         'C-3PO')
            for index, message in enumerate(expected_messages):
                assert message in log_capture.records[index].getMessage()