Exemplo n.º 1
0
def test_parse_cli_args_basic_none():
    args = ["somethingelse", "notrelevant"]
    args = parse_cli_args(args)
    assert args["limit"] is False
    assert args["groups"] is False
    assert args["skip_tags"] == []
    assert args["run_tags"] == []
    assert args["workers"] is False
Exemplo n.º 2
0
def test_patch_inventory_limit_host_ignore_case():
    args = ["-l", "UPPER-HOST"]
    args = parse_cli_args(args)
    nr = InitNornir(
        inventory={
            "plugin": "nornir.plugins.inventory.simple.SimpleInventory",
            "options": {
                "host_file": f"{TEST_DIR}_test_nornir_inventory/hosts.yaml",
                "group_file": f"{TEST_DIR}_test_nornir_inventory/groups.yaml",
            },
        },
        logging={"enabled": False},
    )
    nr.inventory = patch_inventory(args, nr.inventory)
    assert set(nr.inventory.hosts.keys()) == {"UPPER-HOST"}
Exemplo n.º 3
0
def test_patch_inventory_basic_limit_group_invalid():
    args = ["-g", "eos1234"]
    args = parse_cli_args(args)
    nr = InitNornir(
        inventory={
            "plugin": "nornir.plugins.inventory.simple.SimpleInventory",
            "options": {
                "host_file": f"{TEST_DIR}_test_nornir_inventory/hosts.yaml",
                "group_file": f"{TEST_DIR}_test_nornir_inventory/groups.yaml",
            },
        },
        logging={"enabled": False},
    )
    nr.inventory = patch_inventory(args, nr.inventory)
    assert set(nr.inventory.hosts.keys()) == set()
Exemplo n.º 4
0
def test_patch_config_basic_limit_workers():
    args = ["-w", "10"]
    args = parse_cli_args(args)
    nr = InitNornir(
        inventory={
            "plugin": "nornir.plugins.inventory.simple.SimpleInventory",
            "options": {
                "host_file": f"{TEST_DIR}_test_nornir_inventory/hosts.yaml",
                "group_file": f"{TEST_DIR}_test_nornir_inventory/groups.yaml",
            },
        },
        logging={"enabled": False},
    )
    nr.config = patch_config(args, nr.config)
    assert nr.config.core.num_workers == 10
Exemplo n.º 5
0
def test_parse_cli_args_basic_short():
    args = [
        "-l",
        "sea-eos-1",
        "-g",
        "sea",
        "-s",
        "deploy_configs",
        "-t",
        "render_configs",
        "-w",
        "10",
    ]
    args = parse_cli_args(args)
    assert args["limit"] == {"sea-eos-1"}
    assert args["groups"] == {"sea"}
    assert args["skip_tags"] == {"deploy_configs"}
    assert args["run_tags"] == {"render_configs"}
    assert args["workers"] == 10
Exemplo n.º 6
0
def test_parse_cli_args_basic_long():
    args = [
        "--limit",
        "sea-eos-1",
        "--groups",
        "sea",
        "--skip",
        "deploy_configs",
        "--tags",
        "render_configs",
        "--workers",
        "10",
        "--disable-delegate",
    ]
    args = parse_cli_args(args)
    assert args["limit"] == {"sea-eos-1"}
    assert args["groups"] == {"sea"}
    assert args["skip_tags"] == {"deploy_configs"}
    assert args["run_tags"] == {"render_configs"}
    assert args["workers"] == 10