def test_nervosum_parser_input_build_config() -> None: expected = argparse.Namespace(cmd="build", c="a_file", dir=".", nervosum_module="nervosum.core.build") assert expected == parse_args(["build", ".", "-c", "a_file"])
def test_nervosum_parser_input_build_dir() -> None: expected = argparse.Namespace( cmd="build", c="nervosum.yaml", dir=".", nervosum_module="nervosum.core.build", ) assert expected == parse_args(["build", "."])
def test_nervosum_parser_input_ls_filter() -> None: expected = argparse.Namespace( cmd="ls", filter=["key==value", "key2==value2"], nervosum_module="nervosum.core.list", ) assert expected == parse_args( ["ls", "-f", "key==value", "--filter", "key2==value2"])
def test_nervosum_parser_input_run( tag: str, tag_value: str, name: str, name_value: str, run: Callable, ): expected = run(name=name_value, tag=tag_value) args = ["run"] if tag and tag_value: args += [tag, tag_value] if name and name_value: args += [name, name_value] assert expected == parse_args(args)
def main() -> None: args = nervosum_parser.parse_args() module = importlib.import_module(args.nervosum_module) module.execute(args) # type: ignore
def test_nervosum_parser_invalid_command() -> None: with pytest.raises(SystemExit): parse_args(["invalid"])
def test_nervosum_parser_input_build_no_input() -> None: with pytest.raises(SystemExit): parse_args(["build"])
def test_nervosum_parser_input_ls_no_inputs() -> None: expected = argparse.Namespace(cmd="ls", filter=None, nervosum_module="nervosum.core.list") assert expected == parse_args(["ls"])