diff --git a/ckan/tests/helpers.py b/ckan/tests/helpers.py index 998d0fef04a..fcb62d0bb41 100644 --- a/ckan/tests/helpers.py +++ b/ckan/tests/helpers.py @@ -23,11 +23,13 @@ from pylons import config import nose.tools import mock +from flask import Blueprint import ckan.lib.search as search import ckan.config.middleware import ckan.model as model import ckan.logic as logic +import ckan.plugins as p try: @@ -459,3 +461,26 @@ def find_flask_app(test_app): 'a reference to the app they wrap?') else: return find_flask_app(app) + + +class SimpleFlaskPlugin(p.SingletonPlugin): + + ''' + A simple extension that implements the Flask IBlueprint interface. + + This is useful to test a route that we know will be served by Flask. + ''' + + p.implements(p.IBlueprint) + + def flask_plugin_view(self): + return 'Hello World, this is served from a simple Flask extension.' + + def get_blueprint(self): + # Create Blueprint for plugin + blueprint = Blueprint(self.name, self.__module__) + # Add plugin url rule to Blueprint object + blueprint.add_url_rule('/simple_flask', 'flask_plugin_view', + self.flask_plugin_view) + + return blueprint diff --git a/setup.py b/setup.py index 489184820c0..3d12b988e16 100644 --- a/setup.py +++ b/setup.py @@ -165,6 +165,7 @@ 'test_routing_plugin = ckan.tests.config.test_middleware:MockRoutingPlugin', 'test_flash_plugin = ckan.tests.config.test_sessions:FlashMessagePlugin', 'test_helpers_plugin = ckan.tests.lib.test_helpers:TestHelpersPlugin', + 'test_simple_flask_plugin = ckan.tests.helpers:SimpleFlaskPlugin', ], 'babel.extractors': [ 'ckan = ckan.lib.extract:extract_ckan',