def test_non_blueprint_non_rest_error_routing(self, app, mocker):
    blueprint = Blueprint('test', __name__)
    api = restx.Api(blueprint)
    api.add_resource(HelloWorld, '/hi', endpoint='hello')
    api.add_resource(GoodbyeWorld(404), '/bye', endpoint='bye')
    app.register_blueprint(blueprint, url_prefix='/blueprint')

    @app.route('/hi')
    def hi():
        return 'hi'

    @app.route('/bye')
    def bye():
        flask.abort(404)
    with app.test_request_context('/hi', method='POST'):
        assert (api._should_use_fr_error_handler() is False)
        assert (api._has_fr_route() is False)
    with app.test_request_context('/blueprint/hi', method='POST'):
        assert (api._should_use_fr_error_handler() is True)
        assert (api._has_fr_route() is True)
    api._should_use_fr_error_handler = mocker.Mock(return_value=False)
    with app.test_request_context('/bye'):
        assert (api._has_fr_route() is False)
    with app.test_request_context('/blueprint/bye'):
        assert (api._has_fr_route() is True)
def test_non_blueprint_non_rest_error_routing(self, app, mocker):
    blueprint = Blueprint('test', __name__)
    api = restx.Api(blueprint)
    api.add_resource(HelloWorld, '/hi', endpoint='hello')
    api.add_resource(GoodbyeWorld(404), '/bye', endpoint='bye')
    app.register_blueprint(blueprint, url_prefix='/blueprint')

    @app.route('/hi')
    def hi():
        return 'hi'

    @app.route('/bye')
    def bye():
        flask.abort(404)
    with app.test_request_context('/hi', method='POST'):
        assert (api._should_use_fr_error_handler() is False)
        assert (api._has_fr_route() is False)
    with app.test_request_context('/blueprint/hi', method='POST'):
        assert (api._should_use_fr_error_handler() is True)
        assert (api._has_fr_route() is True)
    api._should_use_fr_error_handler = mocker.Mock(return_value=False)
    with app.test_request_context('/bye'):
        assert (api._has_fr_route() is False)
    with app.test_request_context('/blueprint/bye'):
        assert (api._has_fr_route() is True)