Exemplo n.º 1
0
 def test_retrieve_learner_queue(self):
     with patch('tubular.edx_api.BaseApiClient.get_access_token') as mock:
         mock.return_value = ('THIS_IS_A_JWT', None)
         with patch('tubular.edx_api.EdxRestApiClient'):
             lms_api = edx_api.LmsApi('http://localhost:18000',
                                      'http://localhost', 'the_client_id',
                                      'the_client_secret')
             lms_api.learners_to_retire(TEST_RETIREMENT_QUEUE_STATES,
                                        cool_off_days=365)
             # pylint: disable=protected-access
             lms_api._client.api.user.v1.accounts.retirement_queue.get.assert_called_once_with(
                 cool_off_days=365, states=TEST_RETIREMENT_QUEUE_STATES)
Exemplo n.º 2
0
 def test_retrieve_learner_queue_backoff(self, svr_status_code,
                                         mock_backoff_handler):
     mock_backoff_handler.side_effect = BackoffTriedException
     with patch('tubular.edx_api.BaseApiClient.get_access_token'
                ) as mock_get_access_token:
         mock_get_access_token.return_value = ('THIS_IS_A_JWT', None)
         with patch('tubular.edx_api.EdxRestApiClient'):
             lms_api = edx_api.LmsApi('http://localhost:18000',
                                      'http://localhost', 'the_client_id',
                                      'the_client_secret')
             response = requests.Response()
             response.status_code = svr_status_code
             # pylint: disable=protected-access
             lms_api._client.api.user.v1.accounts.retirement_queue.get.side_effect = \
                 HttpServerError(response=response)
             with self.assertRaises(BackoffTriedException):
                 lms_api.learners_to_retire(TEST_RETIREMENT_QUEUE_STATES,
                                            cool_off_days=365)
Exemplo n.º 3
0
 def test_retirement_partner_cleanup_backoff_on_connection_error(self, svr_status_code, mock_backoff_handler):
     mock_backoff_handler.side_effect = BackoffTriedException
     with patch('tubular.edx_api.BaseApiClient.get_access_token') as mock_get_access_token:
         mock_get_access_token.return_value = ('THIS_IS_A_JWT', None)
         with patch('tubular.edx_api.EdxRestApiClient'):
             lms_api = edx_api.LmsApi(
                 'http://localhost:18000',
                 'http://localhost',
                 'the_client_id',
                 'the_client_secret'
             )
             response = requests.Response()
             response.status_code = svr_status_code
             # pylint: disable=protected-access
             lms_api._client.api.user.v1.accounts.retirement_partner_report_cleanup.post.side_effect = \
                 ConnectionError(response=response)
             with self.assertRaises(BackoffTriedException):
                 lms_api.retirement_partner_cleanup([{'original_username': '******'}])