20 行
802 B
Python
20 行
802 B
Python
|
|
import pytest
|
||
|
|
|
||
|
|
from adapters.astrbot_command_parser import parse_single_image_command
|
||
|
|
from backend.dto.chat_command_dto import ChatCommandParseError
|
||
|
|
|
||
|
|
|
||
|
|
def test_parse_natural_and_explicit_single_image_command():
|
||
|
|
command = parse_single_image_command('雨夜街道中的少女 --角色 "米卡" --尺寸 2K --数量 2 --负面 水印')
|
||
|
|
assert command.prompt == "雨夜街道中的少女"
|
||
|
|
assert command.profile_ref == "米卡"
|
||
|
|
assert command.size == "2560x1440"
|
||
|
|
assert command.count == 2
|
||
|
|
assert command.negative_prompt == "水印"
|
||
|
|
|
||
|
|
|
||
|
|
@pytest.mark.parametrize("raw", ["", "测试 --尺寸 8K", "测试 --数量 0", "测试 --未知 x"])
|
||
|
|
def test_parse_rejects_invalid_single_image_commands(raw):
|
||
|
|
with pytest.raises(ChatCommandParseError):
|
||
|
|
parse_single_image_command(raw)
|