def test_parsing_variants_with_iso():
    args = parse_arguments([
        "--variant=BaseOS",
        "--arch=x86_64",
        "--variant=AppStream",
        "--iso",
        "RHEL-8",
        "/tmp/repo",
    ])
    assert args["name"] == "RHEL-8"
    assert args["download_folder"] == "/tmp/repo"
    assert args["archs"] == ["x86_64"]
    assert sorted(args["variants"], key=lambda v: v["name"]) == [
        {
            "name": "AppStream",
            "with_debug": False,
            "with_iso": True
        },
        {
            "name": "BaseOS",
            "with_debug": False,
            "with_iso": True
        },
    ]
    assert args["with_iso"]
Exemple #2
0
def test_parsing_combined_arguments():
    args = parse_arguments([
        "RHEL-8.1",
        "/var/www/html",
        "--variant",
        "BaseOS",
        "--variant",
        "AppStream",
        "--arch",
        "ppc64le",
    ])
    assert args["name"] == "RHEL-8.1"
    assert args["download_folder"] == "/var/www/html"
    assert args["archs"] == ["ppc64le"]
    assert sorted(args["variants"], key=lambda v: v["name"]) == [
        {
            "name": "AppStream",
            "with_debug": False
        },
        {
            "name": "BaseOS",
            "with_debug": False
        },
    ]
    assert not args["with_debug"]
def test_parsing_1_variant():
    args = parse_arguments(["RHEL-8", "/var/www/html", "--variant", "BaseOS"])
    assert args["variants"] == [{
        "name": "BaseOS",
        "with_debug": False,
        "with_iso": False
    }]
Exemple #4
0
def test_parsing_combined_arguments_different_order():
    args = parse_arguments([
        "--variant",
        "BaseOS",
        "--arch",
        "x86_64",
        "--variant",
        "AppStream",
        "RHEL-8.1",
        "/home/dci/repo",
    ])
    assert args["name"] == "RHEL-8.1"
    assert args["download_folder"] == "/home/dci/repo"
    assert args["archs"] == ["x86_64"]
    assert sorted(args["variants"], key=lambda v: v["name"]) == [
        {
            "name": "AppStream",
            "with_debug": False
        },
        {
            "name": "BaseOS",
            "with_debug": False
        },
    ]
    assert not args["with_debug"]
Exemple #5
0
def test_parsing_settings_file():
    args = parse_arguments(["--settings", "/etc/dci-downloader/settings.yml"])
    assert args["name"] is None
    assert args["archs"] == ["x86_64"]
    assert args["variants"] == []
    assert not args["with_debug"]
    assert args["settings_file_path"] == "/etc/dci-downloader/settings.yml"
    assert args["download_folder"] is None
Exemple #6
0
def test_parsing_no_options():
    args = parse_arguments(["RHEL-8", "/var/www/html"])
    assert args["name"] == "RHEL-8"
    assert args["archs"] == ["x86_64"]
    assert args["variants"] == []
    assert not args["with_debug"]
    assert args["settings_file_path"] is None
    assert args["download_folder"] == "/var/www/html"
def test_parsing_component_id():
    args = parse_arguments([
        "RHEL-8",
        "/var/www/html",
        "--component-id",
        "27bbcd7d-021b-4f0a-b04e-e64f1be386f7",
    ])
    assert args["name"] == "RHEL-8"
    assert args["download_folder"] == "/var/www/html"
    assert args["component_id"] == "27bbcd7d-021b-4f0a-b04e-e64f1be386f7"
Exemple #8
0
def get_settings(sys_args, env_variables={}):
    cli_arguments = parse_arguments(sys_args)
    settings = {
        "remoteci_id": _get_remoteci_id(env_variables),
        "env_variables": env_variables,
        "topics": [cli_arguments],
        "download_folder": _get_download_folder(cli_arguments, env_variables),
    }
    settings_file_path = cli_arguments["settings_file_path"]
    if settings_file_path:
        settings_from_file = _read_settings_file(settings_file_path)
        settings.update(_keep_backward_compatibility(settings_from_file))
    return _clean_settings(settings)
Exemple #9
0
def test_parsing_2_variants():
    args = parse_arguments([
        "RHEL-8", "/var/www/html", "--variant", "BaseOS", "--variant",
        "AppStream"
    ])
    assert sorted(args["variants"], key=lambda v: v["name"]) == [
        {
            "name": "AppStream",
            "with_debug": False
        },
        {
            "name": "BaseOS",
            "with_debug": False
        },
    ]
Exemple #10
0
def test_parsing_multiple_settings_file():
    args = parse_arguments([
        "--settings",
        "/etc/dci-downloader/settings.yml",
        "--settings",
        "/etc/dci-downloader/extra.yml",
    ])
    assert args["name"] is None
    assert args["archs"] == ["x86_64"]
    assert args["variants"] == []
    assert not args["with_debug"]
    assert not args["with_iso"]
    # ensure all settings files are present and in the right order
    assert args["settings_file_paths"] == [
        "/etc/dci-downloader/settings.yml", "/etc/dci-downloader/extra.yml"
    ]
    assert args["download_folder"] is None
Exemple #11
0
def get_settings(sys_args, env_variables={}):
    cli_arguments = parse_arguments(sys_args)
    dci_home_path = _get_dci_downloader_home_folder(env_variables)
    key = env_variables.get("DCI_KEY_FILE",
                            os.path.join(dci_home_path, "dci.key"))
    crt = env_variables.get("DCI_CERT_FILE",
                            os.path.join(dci_home_path, "dci.crt"))
    settings = {
        "remoteci_id": _get_remoteci_id(env_variables),
        "env_variables": env_variables,
        "topics": [cli_arguments],
        "download_folder": _get_download_folder(cli_arguments, env_variables),
        "dci_key_file": key,
        "dci_cert_file": crt,
        "registry": _get_registry(cli_arguments, env_variables),
    }
    settings_file_paths = cli_arguments["settings_file_paths"]
    if settings_file_paths:
        settings_from_files = _read_settings_files(settings_file_paths)
        settings.update(_keep_backward_compatibility(settings_from_files))
    return _clean_settings(settings)
Exemple #12
0
def test_parsing_with_iso():
    args = parse_arguments(["RHEL-8", "/var/www/html", "--iso"])
    assert args["with_iso"]
Exemple #13
0
def test_parsing_with_debug():
    args = parse_arguments(["RHEL-8", "/var/www/html", "--debug"])
    assert args["with_debug"]
Exemple #14
0
def test_parsing_no_components():
    args = parse_arguments(["RHEL-8", "/var/www/"])
    assert args["component_id"] is None
Exemple #15
0
def test_parsing_2_archs():
    args = parse_arguments(
        ["RHEL-8", "/var/www/html", "--arch", "x86_64", "--arch", "ppc64le"])
    assert sorted(args["archs"]) == ["ppc64le", "x86_64"]
Exemple #16
0
def test_parsing_1_arch():
    args = parse_arguments(["RHEL-8", "/var/www/html", "--arch", "ppc64le"])
    assert args["archs"] == ["ppc64le"]
Exemple #17
0
def test_parsing_no_option_raise_exception():
    with raises(SystemExit):
        parse_arguments([])
Exemple #18
0
def test_parsing_name():
    args = parse_arguments(["RHEL-7.6", "/var/www/html"])
    assert args["name"] == "RHEL-7.6"