potiuk commented on code in PR #46891:
URL: https://github.com/apache/airflow/pull/46891#discussion_r2160042361


##########
airflow-core/tests/unit/plugins/test_plugin.py:
##########
@@ -44,45 +41,54 @@ def plugin_macro():
     pass
 
 
-# Creating a flask appbuilder BaseView
-class PluginTestAppBuilderBaseView(AppBuilderBaseView):
-    default_view = "test"
-
-    @expose("/")
-    def test(self):
-        return self.render_template("test_plugin/test.html", content="Hello 
galaxy!")
-
-
-v_appbuilder_view = PluginTestAppBuilderBaseView()
-v_appbuilder_package = {
-    "name": "Test View",
-    "category": "Test Plugin",
-    "view": v_appbuilder_view,
-    "label": "Test Label",
-}
-
-v_nomenu_appbuilder_package = {"view": v_appbuilder_view}
-
-# Creating flask appbuilder Menu Items
-appbuilder_mitem = {
-    "name": "Google",
-    "href": "https://www.google.com";,
-    "category": "Search",
-}
-appbuilder_mitem_toplevel = {
-    "name": "apache",
-    "href": "https://www.apache.org/";,
-    "label": "The Apache Software Foundation",
-}
+try:
+    from flask import Blueprint
+    from flask_appbuilder import BaseView as AppBuilderBaseView, expose
+    from starlette.middleware.base import BaseHTTPMiddleware
+
+    # Creating a flask appbuilder BaseView
+    class PluginTestAppBuilderBaseView(AppBuilderBaseView):
+        default_view = "test"
+
+        @expose("/")
+        def test(self):
+            return self.render_template("test_plugin/test.html", 
content="Hello galaxy!")
+
+    v_appbuilder_view = PluginTestAppBuilderBaseView()
+    v_appbuilder_package = {
+        "name": "Test View",
+        "category": "Test Plugin",
+        "view": v_appbuilder_view,
+        "label": "Test Label",
+    }
+
+    v_nomenu_appbuilder_package = {"view": v_appbuilder_view}
+
+    # Creating flask appbuilder Menu Items
+    appbuilder_mitem = {
+        "name": "Google",
+        "href": "https://www.google.com";,
+        "category": "Search",
+    }
+    appbuilder_mitem_toplevel = {
+        "name": "apache",
+        "href": "https://www.apache.org/";,
+        "label": "The Apache Software Foundation",
+    }
+
+    # Creating a flask blueprint to integrate the templates and static folder
+    bp = Blueprint(
+        "test_plugin",
+        __name__,
+        template_folder="templates",  # registers airflow/plugins/templates as 
a Jinja template folder
+        static_folder="static",
+        static_url_path="/static/test_plugin",
+    )
+
+except ImportError:
+    # This test plugin will be silently skipped if fab provider is not 
installed
+    pass

Review Comment:
   It's a bit tricky - but yes. We can likely add more specific import error 
here.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to