def test_primitive_version_range_from_all_none():
    # System under test
    version_range = VersionRange()

    # Verification
    assert version_range is not None

    really_new_version_number = StrictVersion("100.100")
    assert version_range.is_in_range(really_new_version_number)

    really_old_version_number = StrictVersion("3.0")
    assert version_range.is_in_range(really_old_version_number)
def test_primitive_version_range_from_none_end():
    # Setup
    start_version_number = StrictVersion("10.12")

    # System under test
    version_range = VersionRange(start=start_version_number)

    # Verification
    assert version_range is not None

    really_new_version_number = StrictVersion("100.100")
    assert version_range.is_in_range(really_new_version_number)

    really_old_version_number = StrictVersion("3.0")
    assert not version_range.is_in_range(really_old_version_number)
Ejemplo n.º 3
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
def test_primitive_version_range_from_invalid_loose_version():
    # Setup
    some_loose_version = LooseVersion("10.12")

    # System under test
    with pytest.raises(ValueError):
        VersionRange(some_loose_version)
def test_primitive_version_range_from_valid_start_and_ends():
    # Setup
    start_version_number = StrictVersion("10.12")
    end_version_number = StrictVersion("10.15")

    # System under test
    version_range = VersionRange(start_version_number, end_version_number)

    # Verification
    assert version_range is not None

    really_new_version_number = StrictVersion("100.100")
    assert not version_range.is_in_range(really_new_version_number)

    really_old_version_number = StrictVersion("3.0")
    assert not version_range.is_in_range(really_old_version_number)

    valid_in_between_version_number = StrictVersion("10.13")
    assert version_range.is_in_range(valid_in_between_version_number)

    valid_end_edge_version_number = StrictVersion("10.15")
    assert version_range.is_in_range(valid_end_edge_version_number)

    valid_start_edge_version_number = StrictVersion("10.12")
    assert version_range.is_in_range(valid_start_edge_version_number)
def test_primitive_version_range_from_invalid_type_string_both():
    # System under test
    with pytest.raises(ValueError):
        VersionRange(start="10.12", end="10.15")