Skip to content

Commit

Permalink
feat(events-v2): Fix no projects case, add test (#13338)
Browse files Browse the repository at this point in the history
  • Loading branch information
lynnagara authored May 22, 2019
1 parent de5b345 commit 5eb4bfd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 1 addition & 3 deletions src/sentry/api/endpoints/organization_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@ def get_v2(self, request, organization):
except OrganizationEventsError as exc:
return Response({'detail': exc.message}, status=400)
except NoProjects:
# return empty result if org doesn't have projects
# or user doesn't have access to projects in org
data_fn = lambda *args, **kwargs: []
return Response([])
else:
data_fn = partial(
lambda *args, **kwargs: transform_aliases_and_query(*args, **kwargs)['data'],
Expand Down
8 changes: 8 additions & 0 deletions tests/snuba/api/endpoints/test_organization_events_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ def setUp(self):


class OrganizationEventsV2EndpointTest(OrganizationEventsTestBase):
def test_no_projects(self):
self.login_as(user=self.user)
with self.feature('organizations:events-v2'):
response = self.client.get(self.url, format='json')

assert response.status_code == 200, response.content
assert len(response.data) == 0

def test_raw_data(self):
self.login_as(user=self.user)
project = self.create_project()
Expand Down

0 comments on commit 5eb4bfd

Please sign in to comment.