joy-cli/tests/test_web_action_whitelist.py
feibisi 3501583f90 feat(idea): 支持 --author 与 list total_open 修正
面板可传 --author 避免 web 默认 identity 污染;list 统计 open
时缺省 status 按 open。补 web action 白名单单测(idea list 等)。
2026-07-09 16:11:29 +08:00

38 lines
1.2 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""web action 白名单精确匹配与带参前缀idea list 等)"""
import sys
from pathlib import Path
import pytest
SRC = Path(__file__).parent.parent / "src"
sys.path.insert(0, str(SRC))
from joy.commands.web import _check_action # noqa: E402
@pytest.mark.parametrize(
"args,expected",
[
(["idea", "list"], True),
(["idea", "list", "--limit", "20"], True),
(["idea", "list", "--all"], True),
(["idea", "add", "hello"], True),
(["idea", "add", "hello", "body", "--tag", "a,b"], True),
(["idea", "add", "t", "--author", "linuxjoy"], True),
(["idea", "close", "IDEA-1"], True),
(["dashboard", "--json"], True),
(["board", "create", "devops", "desc", "--family", "business"], True),
(["evil", "cmd"], False),
(["idea"], False),
(["idea", "search", "x"], False), # 未进白名单
],
)
def test_check_action_whitelist(args, expected):
assert _check_action(args) is expected
def test_idea_list_exact_not_require_rest():
"""回归takes_arg=True 时不得误杀精确 idea list。"""
assert _check_action(["idea", "list"]) is True
assert _check_action(["idea", "list", "--limit", "50"]) is True