Exemplo n.º 1
0
def alpha_default_parse_data(default_settings_data):
    settings = []
    for raw_setting in default_settings_data:
        name = raw_setting.get("name")
        enabled = raw_setting.get("enabled", True)
        description = raw_setting.get("description")

        raw_start = raw_setting.get("start")
        start = None if raw_start is None else MacVersion.from_name(raw_start)

        raw_end = raw_setting.get("end")
        end = None if raw_end is None else MacVersion.from_name(raw_end)

        valid_version_range = VersionRange(start, end)
        command = raw_setting.get("command")
        check_command = raw_setting.get("check_command")
        expected_check_state = raw_setting.get("expected_check_state")

        run_as_sudo = raw_setting.get("sudo", False)

        check_output = raw_setting.get("check_output", True)
        settings.append(
            Setting(
                name=name,
                valid_version_range=valid_version_range,
                command=command,
                enabled=enabled,
                description=description,
                check_command=check_command,
                expected_check_state=expected_check_state,
                run_as_sudo=run_as_sudo,
                check_output=check_output,
            ))

    return settings
Exemplo n.º 2
0
def test_primitive_mac_version_from_invalid_name_mavericks_gibberish():
    # Setup
    version_string = "asdiajodsiajdoaijdoaisjd"

    # System under test
    with pytest.raises(KeyError):
        MacVersion.from_name(version_string)
Exemplo n.º 3
0
def test_primitive_mac_version_from_invalid_name_none():
    # Setup
    version_string = None

    # System under test
    with pytest.raises(KeyError):
        MacVersion.from_name(version_string)
Exemplo n.º 4
0
def test_primitive_mac_version_from_invalid_name_mavericks_unsupported_version():
    # Setup
    version_string = "mavericks"

    # System under test
    with pytest.raises(KeyError):
        MacVersion.from_name(version_string)
Exemplo n.º 5
0
def test_primitive_mac_version_from_invalid_version_strict_unsupported_version_major_minor():
    # Setup
    version_string = StrictVersion("10.5")

    # System under test
    with pytest.raises(ValueError):
        MacVersion.from_version(version_string)
Exemplo n.º 6
0
def test_primitive_mac_version_from_invalid_version_string_gibberish():
    # Setup
    version_string = "asdoaijsdoaidjoaidsja"

    # System under test
    with pytest.raises(ValueError):
        MacVersion.from_version(version_string)
Exemplo n.º 7
0
def test_primitive_mac_version_from_invalid_version_string_unsupported_version_major_minor_patch():
    # Setup
    version_string = "10.7.3"

    # System under test
    with pytest.raises(ValueError):
        MacVersion.from_version(version_string)
Exemplo n.º 8
0
def test_primitive_mac_version_ordering_from_mixed():
    # Setup
    yosemite = MacVersion.from_version(StrictVersion("10.10.1"))
    mojave = MacVersion.from_version("10.14")
    sierra = MacVersion.from_name("sierra")

    correct_sorted_mac_versions = [MacVersion.YOSEMITE, MacVersion.SIERRA, MacVersion.MOJAVE]
    unsorted_mac_versions = [mojave, sierra, yosemite]

    # System under test
    found_sorted_mac_versions = sorted(unsorted_mac_versions)

    # Verification
    assert correct_sorted_mac_versions == found_sorted_mac_versions
Exemplo n.º 9
0
def test_primitive_mac_version_ordering_from_name():
    # Setup
    yosemite = MacVersion.from_name("yosemite")
    high_sierra = MacVersion.from_name("HIGH_SIERRA")
    mojave = MacVersion.from_name("moJaVe")

    correct_sorted_mac_versions = [MacVersion.YOSEMITE, MacVersion.HIGH_SIERRA, MacVersion.MOJAVE]
    unsorted_mac_versions = [high_sierra, mojave, yosemite]

    # System under test
    found_sorted_mac_versions = sorted(unsorted_mac_versions)

    # Verification
    assert correct_sorted_mac_versions == found_sorted_mac_versions
Exemplo n.º 10
0
def test_primitive_mac_version_from_valid_version_string_major_minor():
    # Setup
    version_string = "10.13.3"

    # System under test
    mac_version = MacVersion.from_version(version_string)

    # Verification
    assert mac_version is not None
    assert isinstance(mac_version, MacVersion)
    assert mac_version == MacVersion.HIGH_SIERRA
Exemplo n.º 11
0
def test_primitive_mac_version_from_valid_name_mojave_string_weirdcase():
    # Setup
    version_string = "mOjAvE"

    # System under test
    mac_version = MacVersion.from_name(version_string)

    # Verification
    assert mac_version is not None
    assert isinstance(mac_version, MacVersion)
    assert mac_version == MacVersion.MOJAVE
Exemplo n.º 12
0
def test_primitive_mac_version_from_valid_version_strict_version_major_minor():
    # Setup
    version_string = StrictVersion("10.10")

    # System under test
    mac_version = MacVersion.from_version(version_string)

    # Verification
    assert mac_version is not None
    assert isinstance(mac_version, MacVersion)
    assert mac_version == MacVersion.YOSEMITE