Exemplo n.º 1
0
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"])
Exemplo n.º 2
0
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", "."])
Exemplo n.º 3
0
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"])
Exemplo n.º 4
0
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)
Exemplo n.º 5
0
def main() -> None:
    args = nervosum_parser.parse_args()
    module = importlib.import_module(args.nervosum_module)
    module.execute(args)  # type: ignore
Exemplo n.º 6
0
def test_nervosum_parser_invalid_command() -> None:
    with pytest.raises(SystemExit):
        parse_args(["invalid"])
Exemplo n.º 7
0
def test_nervosum_parser_input_build_no_input() -> None:
    with pytest.raises(SystemExit):
        parse_args(["build"])
Exemplo n.º 8
0
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"])