def test_500_with_custom_response(self): exc = HttpServerError() exc.content = {'detail': 'some info'} response = 'custom response' res, data = self.json(error_500(self.request, exception=exc, response=response)) eq_(data['error_response'], {'__all__': [response]})
def test_new_tenant_unexpected_error(self, OA_mock): with setup_fb_client() as fb_client_mock: response = MagicMock() response.json.return_value = { 'unknown_error': 'Something went wrong' } response.text = 'Something went wrong' response.status_code = 500 fb_client_mock.create.side_effect = HttpServerError( response=response) OA_mock.get_resource.side_effect = [{ 'companyName': 'fake_company', 'techContact': { 'email': '*****@*****.**' }, 'addressPostal': { 'postalCode': '11111' } }, { 'subscriptionId': 555 }] res = self.client.post('/connector/v1/tenant', headers=self.headers, data=self.new_tenant) fb_client_mock.create.assert_called() assert res.status_code == 500
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)
def raise_http_server_error(*args, **kwargs): raise HttpServerError('Server Error 503: blah blah')
def test_solitude_error_with_content(self): exc = HttpServerError('500') exc.content = {'cache': True} self.solitude.services.status.get.side_effect = exc res, data = self.data() eq_(data['solitude']['error_response'], exc.content)
def test_create_fail2(self): self.bango_patcher.package.post.side_effect = HttpServerError() res = self.client.post(self.payment_list, data=json.dumps(payment_data)) eq_(res.status_code, 500)
def test_500_with_exception(self): exc = HttpServerError() exc.content = {'detail': 'some info'} res, data = self.json(error_500(self.request, exception=exc)) eq_(res.status_code, 500, res) eq_(data['error_response'], exc.content)