kopia lustrzana https://github.com/corrscope/corrscope
[wip] Add unit tests for CLI parser
rodzic
47a8450669
commit
2a19afce5f
|
@ -146,6 +146,8 @@ def main(
|
||||||
if show_gui:
|
if show_gui:
|
||||||
raise OvgenError('GUI not implemented')
|
raise OvgenError('GUI not implemented')
|
||||||
else:
|
else:
|
||||||
|
if not files:
|
||||||
|
raise click.ClickException('Must specify files or folders to play')
|
||||||
if write:
|
if write:
|
||||||
if audio:
|
if audio:
|
||||||
write_path = Path(audio).with_suffix(YAML_NAME)
|
write_path = Path(audio).with_suffix(YAML_NAME)
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
import os
|
||||||
|
import shlex
|
||||||
|
from contextlib import contextmanager
|
||||||
|
from typing import TYPE_CHECKING, List, Tuple, ContextManager, Callable
|
||||||
|
|
||||||
|
import click
|
||||||
|
import pytest
|
||||||
|
from click.testing import CliRunner
|
||||||
|
|
||||||
|
from ovgenpy import cli
|
||||||
|
from ovgenpy.config import yaml
|
||||||
|
from ovgenpy.ovgenpy import Config
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
import pytest_mock
|
||||||
|
|
||||||
|
|
||||||
|
def call_main(args):
|
||||||
|
return CliRunner().invoke(cli.main, args, catch_exceptions=False, standalone_mode=False)
|
||||||
|
|
||||||
|
|
||||||
|
# ovgenpy configuration sinks
|
||||||
|
|
||||||
|
def write_yaml(command):
|
||||||
|
args = shlex.split(command) + ['-w']
|
||||||
|
return call_main(args)
|
||||||
|
|
||||||
|
|
||||||
|
def play(command):
|
||||||
|
args = shlex.split(command) + ['-p']
|
||||||
|
return call_main(args)
|
||||||
|
|
||||||
|
|
||||||
|
# ovgenpy configuration sources
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('runner', [write_yaml, play])
|
||||||
|
def test_no_files(runner):
|
||||||
|
with pytest.raises(click.ClickException):
|
||||||
|
runner('')
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('runner', [write_yaml, play])
|
||||||
|
def test_cwd(runner):
|
||||||
|
runner('.')
|
Ładowanie…
Reference in New Issue