mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-08-07 21:08:34 +03:00
fix: modernize dependency recovery guidance (#5282)
This commit is contained in:
@@ -1092,6 +1092,23 @@ class TestMainMenuUpdate:
|
||||
assert config.providers.openai.api_key == "${UNRELATED_MISSING_KEY}"
|
||||
assert config.providers.openai_codex.proxy == "${CODEX_PROXY}"
|
||||
|
||||
def test_quick_start_openai_codex_reports_incomplete_installation(self, monkeypatch):
|
||||
import oauth_cli_kit
|
||||
|
||||
messages: list[str] = []
|
||||
monkeypatch.delattr(oauth_cli_kit, "get_token")
|
||||
monkeypatch.setattr(
|
||||
onboard_wizard.console,
|
||||
"print",
|
||||
lambda message, *args, **kwargs: messages.append(str(message)),
|
||||
)
|
||||
|
||||
assert onboard_wizard._quick_start_oauth_login(Config(), "openai_codex") is False
|
||||
assert messages == [
|
||||
"[red]This nanobot installation is missing the required oauth-cli-kit package. "
|
||||
"Reinstall or upgrade nanobot-ai using the same installation method.[/red]"
|
||||
]
|
||||
|
||||
def test_quick_start_openai_codex_runs_interactive_login_for_bad_cached_token(
|
||||
self, monkeypatch
|
||||
):
|
||||
|
||||
@@ -686,7 +686,10 @@ def test_provider_login_openai_codex_handles_missing_oauth_symbol(monkeypatch):
|
||||
result = runner.invoke(app, ["provider", "login", "openai-codex"])
|
||||
|
||||
assert result.exit_code == 1
|
||||
assert "oauth_cli_kit not installed" in result.stdout
|
||||
assert (
|
||||
"This nanobot installation is missing the required oauth-cli-kit package. "
|
||||
"Reinstall or upgrade nanobot-ai using the same installation method."
|
||||
) in re.sub(r"\s+", " ", result.stdout)
|
||||
assert result.exception is not None
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from unittest.mock import patch, sentinel
|
||||
|
||||
from nanobot.providers import openai_compat_provider
|
||||
from nanobot.providers.openai_compat_provider import OpenAICompatProvider
|
||||
from nanobot.providers.registry import ProviderSpec
|
||||
|
||||
@@ -59,3 +60,22 @@ async def test_openai_compat_provider_timeout_can_be_overridden_by_env(monkeypat
|
||||
await provider._ensure_client()
|
||||
|
||||
assert mock_async_openai.call_args.kwargs["timeout"] == 45.0
|
||||
|
||||
|
||||
async def test_missing_langfuse_warning_recommends_plugin_command(monkeypatch) -> None:
|
||||
monkeypatch.setenv("LANGFUSE_SECRET_KEY", "secret")
|
||||
monkeypatch.setattr(openai_compat_provider, "AsyncOpenAI", None)
|
||||
|
||||
with (
|
||||
patch("importlib.util.find_spec", return_value=None),
|
||||
patch("openai.AsyncOpenAI") as mock_async_openai,
|
||||
patch("nanobot.providers.openai_compat_provider.logger.warning") as mock_warning,
|
||||
):
|
||||
provider = OpenAICompatProvider(api_key="test-key", api_base="https://example.com/v1")
|
||||
await provider._ensure_client()
|
||||
|
||||
mock_warning.assert_called_once_with(
|
||||
"LANGFUSE_SECRET_KEY is set but langfuse is not installed; "
|
||||
"run `nanobot plugins enable langfuse` to enable tracing"
|
||||
)
|
||||
mock_async_openai.assert_called_once()
|
||||
|
||||
@@ -820,4 +820,6 @@ async def test_olostep_package_missing_returns_install_hint(monkeypatch):
|
||||
tool = _tool(provider="olostep", api_key="olostep-key")
|
||||
result = await tool.execute(query="test query")
|
||||
|
||||
assert result == "Error: olostep package not installed. Run: pip install olostep"
|
||||
assert result == (
|
||||
"Error: Olostep support is not installed. Run `nanobot plugins enable olostep`."
|
||||
)
|
||||
|
||||
@@ -1624,7 +1624,10 @@ def test_openai_codex_oauth_login_reports_missing_oauth_cli_kit(
|
||||
with pytest.raises(WebUISettingsError) as exc:
|
||||
login_oauth_provider({"provider": ["openai-codex"]})
|
||||
|
||||
assert "oauth_cli_kit not installed. Run: pip install oauth-cli-kit" in str(exc.value)
|
||||
assert str(exc.value) == (
|
||||
"This nanobot installation is missing the required oauth-cli-kit package. "
|
||||
"Reinstall or upgrade nanobot-ai using the same installation method."
|
||||
)
|
||||
|
||||
|
||||
def test_github_copilot_oauth_login_reports_missing_oauth_cli_kit(
|
||||
@@ -1642,7 +1645,10 @@ def test_github_copilot_oauth_login_reports_missing_oauth_cli_kit(
|
||||
with pytest.raises(WebUISettingsError) as exc:
|
||||
login_oauth_provider({"provider": ["github-copilot"]})
|
||||
|
||||
assert "oauth_cli_kit not installed. Run: pip install oauth-cli-kit" in str(exc.value)
|
||||
assert str(exc.value) == (
|
||||
"This nanobot installation is missing the required oauth-cli-kit package. "
|
||||
"Reinstall or upgrade nanobot-ai using the same installation method."
|
||||
)
|
||||
|
||||
|
||||
def test_xai_grok_login_starts_fresh_browser_flow_with_proxy(
|
||||
|
||||
Reference in New Issue
Block a user