コード例 #1
0
    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)
コード例 #2
0
    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)
コード例 #3
0
    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)
コード例 #4
0
    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)