def setUp(self):
        # Database
        users = [
            {'id': 1, 'name': 'a'},
            {'id': 2, 'name': 'b'},
            {'id': 3, 'name': 'c'},
        ]

        # Init app
        self.app = app = Flask(__name__)
        self.app.debug = self.app.testing = True
        self.app.test_client_class = FlaskJsonClient

        # Views
        @app.route('/user', methods=['GET'])
        @jsonapi
        def list_users():
            # Just list users
            return users

        @app.route('/user/<int:id>', methods=['GET'])
        @jsonapi
        def get_user(id):
            # Return a user, or http not found
            # Use list_users()
            try:
                return {'user': list_users()[id-1]}
            except IndexError:
                raise NotFound('User #{} not found'.format(id))

        @app.route('/user/<int:id>', methods=['PATCH'])
        @jsonapi
        def patch_user(id):
            # Try custom http codes
            if id == 1:
                return {'error': 'Denied'}, 403

            # Try PATCH method
            req = request.get_json()
            users[id-1] = req['user']
            return users[id-1]

        @app.route('/user/<int:id>', methods=['DELETE'])
        def delete_user(id):
            # Try returning JsonResponse
            if id == 1:
                return JsonResponse({'error': 'Denied'}, 403)

            # Try DELETE method
            del users[id-1]
            return make_json_response(True)
dataset/ETHPy150Open kolypto/py-flask-jsontools/tests/jsonapi-test.py/TestJsonApi.setUp/original