Esempio n. 1
0
    def test_base_edx_client_calls(self, mock_edx_get_course_blocks,
                                   mock_edx_get_provider_courses,
                                   mock_get_oauth_access_token):
        """
        Check that get_course_blocks and get_provider_courses called from the edx api client.

        We use the id of the content source equal to 5 because in fixture this source has type `edx`
        """
        get_available_blocks(4)
        mock_edx_get_course_blocks.assert_called_once()

        get_available_courses(4)
        mock_edx_get_provider_courses.assert_called_once()
Esempio n. 2
0
 def get_context_data(self, **kwargs):
     selected_content_sources = list(
         map(int, self.request.GET.getlist('content_source', [])))
     activities = Activity.objects.filter(
         collection=self.object).select_related('lti_content_source')
     context = super().get_context_data(**kwargs)
     context['render_fields'] = [
         'name', 'tags', 'difficulty', 'points', 'source'
     ]
     context['activities'] = activities
     context['not_active_content_source'] = activities.filter(
         lti_content_source__is_active=False).order_by(
             "lti_content_source").distinct(
                 "lti_content_source").values_list(
                     'lti_content_source__name', flat=True)
     context['content_sources'] = self.get_content_source_list(
         selected_content_sources)
     context['source_courses'], context[
         'errors_content_source'] = get_available_courses(
             self.request, selected_content_sources)
     context['activity_form'] = ActivityForm(
         initial={'collection': self.object})
     context['sync_available'] = self.object.collection_groups.exists()
     engine_failure = self.request.GET.get('engine')
     if engine_failure:
         context['engine'] = engine_failure
     return context
Esempio n. 3
0
    def test_base_api_client_calls(self, mock_base_get_course_blocks,
                                   mock_edx_get_course_blocks,
                                   mock_base_get_provider_courses,
                                   mock_edx_get_provider_courses):
        """
        Check that get_course_blocks and get_provider_courses called from the correct place.

        We use the id of the content source equal to 5 because in fixture this source has type `base`
        """
        get_available_blocks(5)
        mock_base_get_course_blocks.assert_called_once()
        mock_edx_get_course_blocks.assert_not_called()

        get_available_courses(5)
        mock_base_get_provider_courses.assert_called_once()
        mock_edx_get_provider_courses.assert_not_called()
Esempio n. 4
0
 def get_content_courses(selected_content_sources):
     try:
         return get_available_courses(selected_content_sources)
     except HttpClientError:
         log.exception(
             "There are no active LTI Content Providers. Enable one by setting via Bridge admin site"
             "LtiConsumer.is_active=True.")
         return []