Fix non-root proxy tests

This commit is contained in:
yuneng-jiang 2026-01-22 11:15:18 -08:00
parent dbe6f66baf
commit a7bafadd26

View file

@ -17,8 +17,13 @@ def test_restructure_ui_html_files_skipped_in_non_root(monkeypatch):
ui_path = "/var/lib/litellm/ui"
# Mock the _restructure_ui_html_files function to check if it's called
# Use create=True to allow patching even if the module hasn't been imported yet
# or if the function doesn't exist (it's defined inside a try/except block)
# spec=False prevents spec checking which can fail during import resolution
with patch(
"litellm.proxy.proxy_server._restructure_ui_html_files"
"litellm.proxy.proxy_server._restructure_ui_html_files",
create=True,
spec=False,
) as mock_restructure:
# Simulate the logic we added in proxy_server.py
if is_non_root and ui_path == "/var/lib/litellm/ui":
@ -40,8 +45,13 @@ def test_restructure_ui_html_files_NOT_skipped_locally(monkeypatch):
is_non_root = False
ui_path = "/some/local/path"
# Use create=True and spec=False to allow patching even if the module hasn't been imported yet
# or if the function doesn't exist (it's defined inside a try/except block)
# spec=False prevents spec checking which can fail during import resolution
with patch(
"litellm.proxy.proxy_server._restructure_ui_html_files"
"litellm.proxy.proxy_server._restructure_ui_html_files",
create=True,
spec=False,
) as mock_restructure:
if is_non_root and ui_path == "/var/lib/litellm/ui":
pass