mirror of
https://github.com/shirayu/whispering.git
synced 2024-11-25 10:21:00 +00:00
Improved test
This commit is contained in:
parent
256bf38b4d
commit
62b6d9a3b0
1 changed files with 18 additions and 11 deletions
|
@ -4,23 +4,30 @@
|
||||||
import sys
|
import sys
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
from pydantic import BaseModel
|
||||||
|
|
||||||
from whispering.cli import get_opts, is_valid_arg
|
from whispering.cli import get_opts, is_valid_arg
|
||||||
|
|
||||||
|
|
||||||
|
class ArgExample(BaseModel):
|
||||||
|
cmd: str
|
||||||
|
ok: bool
|
||||||
|
|
||||||
|
|
||||||
def test_options():
|
def test_options():
|
||||||
|
|
||||||
invalid_args = [
|
exs = [
|
||||||
"--mode server --mic 0",
|
ArgExample(cmd="--mode server --mic 0", ok=False),
|
||||||
"--mode server --mic 1",
|
ArgExample(cmd="--mode server --mic 1", ok=False),
|
||||||
"--mode server --beam_size 3",
|
ArgExample(cmd="--mode server --beam_size 3", ok=False),
|
||||||
"--mode server --temperature 0",
|
ArgExample(cmd="--mode server --temperature 0", ok=False),
|
||||||
"--mode server --num_block 3",
|
ArgExample(cmd="--mode server --num_block 3", ok=False),
|
||||||
"--mode mic --host 0.0.0.0",
|
ArgExample(cmd="--mode mic --host 0.0.0.0", ok=False),
|
||||||
"--mode mic --port 8000",
|
ArgExample(cmd="--mode mic --port 8000", ok=False),
|
||||||
]
|
]
|
||||||
|
|
||||||
for invalid_arg in invalid_args:
|
for ex in exs:
|
||||||
with patch.object(sys, "argv", [""] + invalid_arg.split()):
|
with patch.object(sys, "argv", [""] + ex.cmd.split()):
|
||||||
opts = get_opts()
|
opts = get_opts()
|
||||||
ok = is_valid_arg(opts)
|
ok = is_valid_arg(opts)
|
||||||
assert ok is False, f"{invalid_arg} should be invalid"
|
assert ok is ex.ok, f"{ex.cmd} should be invalid"
|
||||||
|
|
Loading…
Reference in a new issue