test: consolidate repetitive cases across the suite

This commit is contained in:
chengyongru authored and chengyongru committed 2026-09-25 14:28:21 +08:00
1 parent c406024b59
commit 6eccc2859a
31 files changed
+745 -1315

No files matched your search

+12 -20
View File
@@ -1,10 +1,19 @@
from types import SimpleNamespace
import pytest
from nanobot.cli.webui_support import _prepare_webui_bundle_for_gateway
from nanobot.config.schema import Config
def test_source_checkout_preserves_warn_only_gateway_startup(monkeypatch) -> None:
@pytest.mark.parametrize(
"mode",
[
pytest.param("warn", id="source_checkout_preserves_warn_only_gateway_startup"),
pytest.param("skip", id="skip_mode_does_not_build_the_source_webui_bundle"),
],
)
def test_source_checkout_respects_webui_build_mode(monkeypatch, mode) -> None:
modes: list[str] = []
monkeypatch.setattr(
"nanobot.cli.webui_support.inspect_webui_bundle",
@@ -16,23 +25,6 @@ def test_source_checkout_preserves_warn_only_gateway_startup(monkeypatch) -> Non
lambda **kwargs: modes.append(kwargs["mode"]),
)
_prepare_webui_bundle_for_gateway(Config(), mode="warn")
_prepare_webui_bundle_for_gateway(Config(), mode=mode)
assert modes == ["warn"]
def test_skip_mode_does_not_build_the_source_webui_bundle(monkeypatch) -> None:
modes: list[str] = []
monkeypatch.setattr(
"nanobot.cli.webui_support.inspect_webui_bundle",
lambda: SimpleNamespace(source_available=True),
)
monkeypatch.setattr("nanobot.cli.webui_support._webui_channel_enabled", lambda _config: True)
monkeypatch.setattr(
"nanobot.cli.webui_support.ensure_webui_bundle",
lambda **kwargs: modes.append(kwargs["mode"]),
)
_prepare_webui_bundle_for_gateway(Config(), mode="skip")
assert modes == ["skip"]
assert modes == [mode]