Skip to content

Commit

Permalink
Some serializer additions and details test
Browse files Browse the repository at this point in the history
  • Loading branch information
dcramer committed Oct 29, 2013
1 parent 7c4fd7b commit b18a35d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/sentry/api/endpoints/group_details.py
Expand Up @@ -46,7 +46,8 @@ class GroupSerializer(serializers.ModelSerializer):

class Meta:
model = Group
fields = ('status',)
fields = ('id', 'status', 'times_seen', 'last_seen', 'first_seen', 'resolved_at', 'active_at')
read_only_fields = ('id', 'times_seen', 'last_seen', 'first_seen', 'resolved_at', 'active_at')


class GroupDetailsView(BaseView):
Expand All @@ -56,8 +57,9 @@ def get(self, request, team, project, group_id):
id=group_id,
project=project,
)
serializer = GroupSerializer(group)

return Response(transform(group, request))
return Response(serializer.data)

@method_decorator(has_access)
def put(self, request, team, project, group_id):
Expand Down
27 changes: 27 additions & 0 deletions tests/sentry/api/endpoints/test_group_details.py
Expand Up @@ -5,6 +5,33 @@
from sentry.testutils import BaseTestCase


class GroupDetailsTest(BaseTestCase, APITestCase):
def test_simple(self):
self.client.force_authenticate(user=self.user)

group = self.create_group()

url = reverse('sentry-api-0-group-details', kwargs={
'project_id': self.project.slug,
'team_slug': self.team.slug,
'group_id': group.id,
})
response = self.client.get(url, format='json')

assert response.status_code == 200, response.content
# TODO: we should move most of this to a serializer test and just
# confirm the ID
assert response.data == {
'id': group.id,
'active_at': group.active_at,
'last_seen': group.last_seen,
'first_seen': group.first_seen,
'resolved_at': None,
'status': 'unresolved',
'times_seen': 1,
}


class GroupUpdateTest(BaseTestCase, APITestCase):
def test_simple(self):
self.client.force_authenticate(user=self.user)
Expand Down

0 comments on commit b18a35d

Please sign in to comment.