@@ -120,3 +120,77 @@ class TestNonPropertyHook(BaseHook):
120120 self .assertIn ('AirflowTestPropertyPlugin' , str (plugins_manager .plugins ))
121121 self .assertIn ('PluginPropertyOperator' , str (plugins_manager .operators_modules [0 ].__dict__ ))
122122 self .assertIn ("TestNonPropertyHook" , str (plugins_manager .hooks_modules [0 ].__dict__ ))
123+
124+ def test_should_warning_about_incompatible_plugins (self ):
125+ class AirflowAdminViewsPlugin (AirflowPlugin ):
126+ name = "test_admin_views_plugin"
127+
128+ admin_views = [mock .MagicMock ()]
129+
130+ class AirflowAdminMenuLinksPlugin (AirflowPlugin ):
131+ name = "test_menu_links_plugin"
132+
133+ menu_links = [mock .MagicMock ()]
134+
135+ with mock_plugin_manager (plugins = [
136+ AirflowAdminViewsPlugin (),
137+ AirflowAdminMenuLinksPlugin ()
138+ ]):
139+ from airflow import plugins_manager
140+
141+ # assert not logs
142+ with self .assertLogs (plugins_manager .log ) as cm :
143+ plugins_manager .initialize_web_ui_plugins ()
144+
145+ self .assertEqual (cm .output , [
146+ 'WARNING:airflow.plugins_manager:Plugin \' test_admin_views_plugin\' may not be '
147+ 'compatible with the current Airflow version. Please contact the author of '
148+ 'the plugin.' ,
149+ 'WARNING:airflow.plugins_manager:Plugin \' test_menu_links_plugin\' may not be '
150+ 'compatible with the current Airflow version. Please contact the author of '
151+ 'the plugin.'
152+ ])
153+
154+ def test_should_not_warning_about_fab_plugins (self ):
155+ class AirflowAdminViewsPlugin (AirflowPlugin ):
156+ name = "test_admin_views_plugin"
157+
158+ appbuilder_views = [mock .MagicMock ()]
159+
160+ class AirflowAdminMenuLinksPlugin (AirflowPlugin ):
161+ name = "test_menu_links_plugin"
162+
163+ appbuilder_menu_items = [mock .MagicMock ()]
164+
165+ with mock_plugin_manager (plugins = [
166+ AirflowAdminViewsPlugin (),
167+ AirflowAdminMenuLinksPlugin ()
168+ ]):
169+ from airflow import plugins_manager
170+
171+ # assert not logs
172+ with self .assertRaises (AssertionError ), self .assertLogs (plugins_manager .log ):
173+ plugins_manager .initialize_web_ui_plugins ()
174+
175+ def test_should_not_warning_about_fab_and_flask_admin_plugins (self ):
176+ class AirflowAdminViewsPlugin (AirflowPlugin ):
177+ name = "test_admin_views_plugin"
178+
179+ admin_views = [mock .MagicMock ()]
180+ appbuilder_views = [mock .MagicMock ()]
181+
182+ class AirflowAdminMenuLinksPlugin (AirflowPlugin ):
183+ name = "test_menu_links_plugin"
184+
185+ menu_links = [mock .MagicMock ()]
186+ appbuilder_menu_items = [mock .MagicMock ()]
187+
188+ with mock_plugin_manager (plugins = [
189+ AirflowAdminViewsPlugin (),
190+ AirflowAdminMenuLinksPlugin ()
191+ ]):
192+ from airflow import plugins_manager
193+
194+ # assert not logs
195+ with self .assertRaises (AssertionError ), self .assertLogs (plugins_manager .log ):
196+ plugins_manager .initialize_web_ui_plugins ()
0 commit comments