Example #1
0
    def test_command_client_error(self):
        """
        Make command handles networking issues gracefully.
        """
        logger = logging.getLogger('integrated_channels.xapi.management.commands.send_course_completions')
        handler = MockLoggingHandler(level="DEBUG")
        logger.addHandler(handler)

        xapi_config = factories.XAPILRSConfigurationFactory()
        call_command('send_course_completions', enterprise_customer_uuid=xapi_config.enterprise_customer.uuid)
        expected_message = (
            'Client error while sending course completion to xAPI for enterprise '
            'customer: {enterprise_customer}'.format(enterprise_customer=xapi_config.enterprise_customer.name)
        )
        assert expected_message in handler.messages['error'][0]
Example #2
0
 def test_get_catalog_results_with_exception(self):
     """
     Verify `get_catalog_results` of CourseCatalogApiClient works as expected in case of exception.
     """
     responses.add(
         responses.POST,
         url=urljoin(self.api.catalog_url, self.api.SEARCH_ALL_ENDPOINT),
         body=HttpClientError(content='boom'),
     )
     logger = logging.getLogger('enterprise.api_client.discovery')
     handler = MockLoggingHandler(level="ERROR")
     logger.addHandler(handler)
     assert self.api.get_catalog_results(content_filter_query='query',
                                         query_params={'page': 2}) == {
                                             'next': None,
                                             'previous': None,
                                             'results': [],
                                         }
     expected_message = 'Failed to retrieve data from the catalog API. content -- [boom]'
     assert handler.messages['error'][0] == expected_message
 def test_get_catalog_results_with_exception(self):
     """
     Verify `get_catalog_results` of CourseCatalogApiClient works as expected in case of exception.
     """
     responses.add(
         responses.POST,
         url=urljoin(self.api.catalog_url, self.api.SEARCH_ALL_ENDPOINT),
         body=HttpClientError(content='boom'),
     )
     logger = logging.getLogger('enterprise.api_client.discovery')
     handler = MockLoggingHandler(level="ERROR")
     logger.addHandler(handler)
     with self.assertRaises(HttpClientError):
         self.api.get_catalog_results(
             content_filter_query='query',
             query_params={u'page': 2}
         )
     expected_message = ('Attempted to call course-discovery search/all/ endpoint with the following parameters: '
                         'content_filter_query: query, query_params: {}, traverse_pagination: False. '
                         'Failed to retrieve data from the catalog API. content -- [boom]').format({u'page': 2})
     assert handler.messages['error'][0] == expected_message
Example #4
0
 def setUpClass(cls):
     super(TestBenchmarkDoctor, cls).setUpClass()
     doctor_log = logging.getLogger('BenchmarkDoctor')
     cls._doctor_log_handler = MockLoggingHandler(level='DEBUG')
     doctor_log.addHandler(cls._doctor_log_handler)