def test_read_404(self): class GroupResource(ModelResource): model = Group request = self.req.get('/groups') mixin = ReadModelMixin() mixin.resource = GroupResource self.assertRaises(ErrorResponse, mixin.get, request, id=12345)
def test_read(self): Group.objects.create(name='other group') group = Group.objects.create(name='my group') class GroupResource(ModelResource): model = Group request = self.req.get('/groups') mixin = ReadModelMixin() mixin.resource = GroupResource response = mixin.get(request, id=group.id) self.assertEquals(group.name, response.name)