def test_500_response(self): responses.add( method=responses.GET, url= u"https://example.com/get-issues?installationId={}&projectSlug={}". format(self.install.uuid, self.project.slug), body="Something failed", status=500, ) with self.assertRaises(APIError): SelectRequester.run( install=self.install, project=self.project, group=self.group, uri="/get-issues", fields={}, ) buffer = SentryAppWebhookRequestsBuffer(self.sentry_app) requests = buffer.get_requests() assert len(requests) == 1 assert requests[0]["response_code"] == 500 assert requests[0]["event_type"] == "select_options.requested"
def test_makes_request(self): options = [ {"label": "An Issue", "value": "123", "default": True}, {"label": "Another Issue", "value": "456"}, ] responses.add( method=responses.GET, url=f"https://example.com/get-issues?installationId={self.install.uuid}&projectSlug={self.project.slug}", json=options, status=200, content_type="application/json", ) result = SelectRequester.run(install=self.install, project=self.project, uri="/get-issues") assert result == { "choices": [["123", "An Issue"], ["456", "Another Issue"]], "defaultValue": "123", } request = responses.calls[0].request assert request.headers["Sentry-App-Signature"] buffer = SentryAppWebhookRequestsBuffer(self.sentry_app) requests = buffer.get_requests() assert len(requests) == 1 assert requests[0]["response_code"] == 200 assert requests[0]["event_type"] == "select_options.requested"
def test_500_response(self): responses.add( method=responses.GET, url='https://example.com/get-issues?projectSlug=boop&installationId=f3d37e3a-9a87-4651-8463-d375118f4996', body='Something failed', status=500, ) with self.assertRaises(APIError): SelectRequester.run( install=self.install, project=self.project, group=self.group, uri='/get-issues', fields={}, )
def test_invalid_response_format(self): # missing 'label' invalid_format = {"value": "12345"} responses.add( method=responses.GET, url=f"https://example.com/get-issues?installationId={self.install.uuid}&projectSlug={self.project.slug}", json=invalid_format, status=200, content_type="application/json", ) with self.assertRaises(APIError): SelectRequester.run( install=self.install, project=self.project, group=self.group, uri="/get-issues", fields={}, )
def test_500_response(self): responses.add( method=responses.GET, url=u'https://example.com/get-issues?installationId={}&projectSlug={}'.format( self.install.uuid, self.project.slug, ), body='Something failed', status=500, ) with self.assertRaises(APIError): SelectRequester.run( install=self.install, project=self.project, group=self.group, uri='/get-issues', fields={}, )
def test_invalid_response_format(self): # missing 'label' invalid_format = { 'value': '12345', } responses.add( method=responses.GET, url='https://example.com/get-issues?projectSlug=boop&installationId=f3d37e3a-9a87-4651-8463-d375118f4996', json=invalid_format, status=200, content_type='application/json', ) with self.assertRaises(APIError): SelectRequester.run( install=self.install, project=self.project, group=self.group, uri='/get-issues', fields={}, )
def test_invalid_response_format(self): # missing 'label' invalid_format = { 'value': '12345', } responses.add( method=responses.GET, url=u'https://example.com/get-issues?installationId={}&projectSlug={}'.format( self.install.uuid, self.project.slug, ), json=invalid_format, status=200, content_type='application/json', ) with self.assertRaises(APIError): SelectRequester.run( install=self.install, project=self.project, group=self.group, uri='/get-issues', fields={}, )
def test_makes_request(self): responses.add( method=responses.GET, url= 'https://example.com/get-issues?projectSlug=boop&installationId=f3d37e3a-9a87-4651-8463-d375118f4996', body='[{"label": "An Issue", "value": "12345"}]', status=200, content_type='application/json', ) result = SelectRequester.run( install=self.install, project=self.project, uri='/get-issues', ) assert result == [{'value': '12345', 'label': 'An Issue'}] request = responses.calls[0].request assert request.headers['Sentry-App-Signature']
def test_makes_request(self): options = [ { 'label': 'An Issue', 'value': '123', 'default': True, }, { 'label': 'Another Issue', 'value': '456', }, ] responses.add( method=responses.GET, url=u'https://example.com/get-issues?installationId={}&projectSlug={}'.format( self.install.uuid, self.project.slug, ), json=options, status=200, content_type='application/json', ) result = SelectRequester.run( install=self.install, project=self.project, uri='/get-issues', ) assert result == { 'choices': [ ['123', 'An Issue'], ['456', 'Another Issue'] ], 'defaultValue': '123', } request = responses.calls[0].request assert request.headers['Sentry-App-Signature']
def test_makes_request(self): options = [ { 'label': 'An Issue', 'value': '123', 'default': True, }, { 'label': 'Another Issue', 'value': '456', }, ] responses.add( method=responses.GET, url='https://example.com/get-issues?projectSlug=boop&installationId=f3d37e3a-9a87-4651-8463-d375118f4996', json=options, status=200, content_type='application/json', ) result = SelectRequester.run( install=self.install, project=self.project, uri='/get-issues', ) assert result == { 'choices': [ ['An Issue', '123'], ['Another Issue', '456'] ], 'default': ['An Issue', '123'], } request = responses.calls[0].request assert request.headers['Sentry-App-Signature']
def _request(self, uri, dependent_data=None): return SelectRequester.run(install=self.install, project=self.project, uri=uri, dependent_data=dependent_data)
def _request(self, uri): return SelectRequester.run(install=self.install, project=self.project, uri=uri)
def _request(self, uri): return SelectRequester.run( install=self.install, project=self.project, uri=uri, )