项目文件夹

文件
wehub-resource-sync 4b6817381b
CI (OpenClaw E2E) / openclaw test (push) Has been cancelled
CI / coverage-report (push) Has been cancelled
CI / test-kubernetes (push) Has been cancelled
CI / should-run-thorough (push) Has been cancelled
CI / test-thorough (cloudwatch-demo) (push) Has been cancelled
CI / test-thorough (flink-ecs) (push) Has been cancelled
CI / test-thorough (upstream-lambda) (push) Has been cancelled
CI / test-thorough (prefect-ecs-fargate) (push) Has been cancelled
Release / build-binaries (zip, opensre.exe, onefile, windows-latest, windows-x64) (push) Has been cancelled
Benchmark image — build + push to ECR (any adapter) / build + push (push) Has been cancelled
CI / quality (ubuntu-latest) (push) Has been cancelled
CI / test (tools-runtime) (push) Has been cancelled
CI / test (e2e-general) (push) Has been cancelled
CI / test (cli-runtime) (push) Has been cancelled
CI / test (e2e-provider-and-openclaw) (push) Has been cancelled
CI / test (integrations-and-misc) (push) Has been cancelled
Release / verify (push) Has been cancelled
Release / build-python-dist (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, macos-15-intel, darwin-x64) (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, macos-latest, darwin-arm64) (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04, linux-x64) (push) Has been cancelled
Release / publish-release (push) Has been cancelled
Release / publish-main-release (push) Has been cancelled
Interactive Shell Live (PR + post-merge) / turn-checks (no-LLM) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Interactive Shell Live (PR + post-merge) / turn-live shard ${{ matrix.shard_index }} (push) Has been cancelled
Release / prepare (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04-arm, linux-arm64) (push) Has been cancelled
Synthetic Deterministic Tests / Synthetic offline (deterministic) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:10:45 +08:00

111 行
3.9 KiB
Python

此文件含有模棱两可的 Unicode 字符
此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。
"""Tests for onboard integration picker taxonomy."""
from __future__ import annotations
import questionary
from surfaces.cli.wizard._ui import Choice, _group_header_label, _grouped_questionary_choices
from surfaces.cli.wizard.onboard_integrations import (
ONBOARD_INTEGRATION_CHOICES,
ONBOARD_INTEGRATION_GROUP_ORDER,
ONBOARD_SKIP_CHOICE,
)
from surfaces.cli.wizard.prompts import _SelectControl
def test_group_header_label_formats_category_title() -> None:
assert _group_header_label("Observability") == "── Observability ──"
def test_select_control_renders_group_headers_with_highlight_style() -> None:
ic = _SelectControl(
[
questionary.Separator(_group_header_label("Observability")),
questionary.Choice("Datadog", value="datadog"),
],
None,
pointer="",
initial_choice="datadog",
show_description=False,
)
rendered = "".join(text for _style, text in ic._get_choice_tokens())
assert "── Observability ──" in rendered
assert any(style == "class:group-header" for style, _text in ic._get_choice_tokens())
def test_onboard_integration_choices_have_unique_values_and_valid_groups() -> None:
values = [choice.value for choice in ONBOARD_INTEGRATION_CHOICES]
assert len(values) == len(set(values))
assert ONBOARD_SKIP_CHOICE.value not in values
for choice in ONBOARD_INTEGRATION_CHOICES:
assert choice.group in ONBOARD_INTEGRATION_GROUP_ORDER
def _expected_grouped_choice_values(
choices: tuple[Choice, ...] | list[Choice],
*,
group_order: tuple[str, ...],
trailing_choices: list[Choice] | None = None,
) -> list[str]:
"""Build selectable values in the same order as ``_grouped_questionary_choices``."""
grouped_values: dict[str, list[str]] = {group: [] for group in group_order}
for choice in choices:
if choice.group in grouped_values:
grouped_values[choice.group].append(choice.value)
ordered_values: list[str] = []
for group in group_order:
ordered_values.extend(grouped_values[group])
if trailing_choices:
ordered_values.extend(choice.value for choice in trailing_choices)
return ordered_values
def test_grouped_questionary_choices_renders_category_separators() -> None:
rendered = _grouped_questionary_choices(
list(ONBOARD_INTEGRATION_CHOICES),
group_order=ONBOARD_INTEGRATION_GROUP_ORDER,
trailing_choices=[ONBOARD_SKIP_CHOICE],
)
separator_titles = [item.title for item in rendered if isinstance(item, questionary.Separator)]
assert separator_titles[: len(ONBOARD_INTEGRATION_GROUP_ORDER)] == [
_group_header_label(group) for group in ONBOARD_INTEGRATION_GROUP_ORDER
]
assert len(separator_titles) == len(ONBOARD_INTEGRATION_GROUP_ORDER) + 1
selectable_values = [
item.value
for item in rendered
if isinstance(item, questionary.Choice) and not isinstance(item, questionary.Separator)
]
assert selectable_values == _expected_grouped_choice_values(
ONBOARD_INTEGRATION_CHOICES,
group_order=ONBOARD_INTEGRATION_GROUP_ORDER,
trailing_choices=[ONBOARD_SKIP_CHOICE],
)
def test_grouped_questionary_choices_labels_unknown_groups_as_other() -> None:
rendered = _grouped_questionary_choices(
[
Choice(value="datadog", label="Datadog", group="Observability"),
Choice(value="custom", label="Custom", group="Unknown"),
],
group_order=("Observability",),
)
separator_titles = [item.title for item in rendered if isinstance(item, questionary.Separator)]
assert separator_titles == [
_group_header_label("Observability"),
_group_header_label("Other"),
]
selectable_values = [
item.value
for item in rendered
if isinstance(item, questionary.Choice) and not isinstance(item, questionary.Separator)
]
assert selectable_values == ["datadog", "custom"]