anasatzemoso commented on code in PR #55262:
URL: https://github.com/apache/airflow/pull/55262#discussion_r2355185853


##########
airflow-core/tests/unit/api_fastapi/test_app.py:
##########
@@ -90,3 +94,20 @@ def test_catch_all_route_last(client):
     """
     test_app = client(apps="all").app
     assert test_app.routes[-1].path == "/{rest_of_path:path}"
+
+def test_plugin_with_empty_url_prefix(caplog):
+    app = FastAPI()
+    with mock.patch.object(plugins_manager, "fastapi_apps", [{"name": "test", 
"app": FastAPI(), "url_prefix": ""}]):
+        app_module.init_plugins(app)
+
+    assert any("'url_prefix' key is empty string" in rec.message for rec in 
caplog.records)
+    assert not any(r.path == "" for r in app.routes)
+
+def test_plugin_with_reserved_url_prefix(caplog):
+    app = FastAPI()
+    reserved = next(iter(app_module.RESERVED_URL_PREFIXES))
+    with mock.patch.object(plugins_manager, "fastapi_apps", [{"name": "test", 
"app": FastAPI(), "url_prefix": reserved}]):
+        app_module.init_plugins(app)
+
+    assert any("attempted to use reserved url_prefix" in rec.message for rec 
in caplog.records)
+    assert not any(r.path == reserved for r in app.routes)

Review Comment:
   Done.



-- 
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