Esempio n. 1
0
def test_if_version_successful() -> None:
    """
    Notes:
        This can fail if Version raises an IndexError or a TypeError.

    Returns:
        Nothing will be returned.
    """
    with not_raises((IndexError, TypeError)):
        Version("0.1.0")
Esempio n. 2
0
def test_if_label_value_is_correct(version_string: str) -> None:
    """
    Notes:
        This can fail if the version object label value isn't the same as the actual label value.

    Args:
        version_string: The version string.

    Returns:
        Nothing will be returned.
    """
    version: Version = Version(version_string)
    actual_label_value: str = version_string.split(".")[3]
    assert version.label == actual_label_value
Esempio n. 3
0
def test_if_micro_value_is_correct(version_string: str) -> None:
    """
    Notes:
        This can fail if the version object micro value isn't the same as the actual micro value.

    Args:
        version_string: The version string.

    Returns:
        Nothing will be returned.
    """
    version: Version = Version(version_string)
    actual_micro_value: int = int(version_string.split(".")[2])
    assert version.micro == actual_micro_value
Esempio n. 4
0
def test_if_given_version_is_the_same_as_version_property(
        version_string: str) -> None:
    """
    Notes:
        This can fail if the version string passed to Version isn't the same as the version property.

    Args:
        version_string: The version string.

    Returns:
        Nothing will be returned.
    """
    version: Version = Version(version_string)
    assert version.version == version_string
Esempio n. 5
0
def test_if_letters_raises_type_error(version_string: str) -> None:
    """
    Notes:
        This can fail if Version doesn't raise a TypeError regardless if there are letters in the string outside the
        label.

    Args:
        version_string: The version string.

    Returns:
        Nothing will be returned.
    """
    with pytest.raises(TypeError):
        Version(version_string)
Esempio n. 6
0
def test_if_less_than_three_digits_raises_index_error(
        version_string: str) -> None:
    """
    Notes:
        This can fail if Version doesn't raise an IndexError regardless if there are 3 or less digits passed.

    Args:
        version_string: The version string.

    Returns:
        Nothing will be returned.
    """
    with pytest.raises(IndexError):
        Version(version_string)
Esempio n. 7
0
def test_if_version_as_data_checks_out(version_string: str,
                                       version_data: VersionData) -> None:
    """
    Notes:
        This can fail if the passed version_data argument isn't the same as the version.as_data data.

    Args:
        version_string: The version string.
        version_data: The version data.

    Returns:
        Nothing will be returned.
    """
    version: Version = Version(version_string)
    assert version.as_data == version_data
Esempio n. 8
0
def test_if_bumped_micro_value_is_correct(
        version_string: str, bumped_micro_value_string: int) -> None:
    """
    Notes:
        This test can fail if the newly bumped micro value version name isn't the same as the bumped_micro_value_string.

    Args:
        version_string: The version string.
        bumped_micro_value_string: The bumped micro value string.

    Returns:
        Nothing will be returned.
    """
    version: Version = Version(version_string)
    version.bump_micro()
    assert version.name == bumped_micro_value_string
Esempio n. 9
0
def test_writing_to_disk(version_string: str) -> None:
    """
    Notes:
        This test can fail if either:
        a.) The file that should've been created by write_to_disk doesn't exist, or
        b.) The text generated by write_to_disk is not equal to the version string.

    Args:
        version_string: The version string.

    Returns:
        Nothing will be returned.
    """
    version: Version = Version(version_string)
    path: str = os.path.join(".", "VERSION")
    version.write_to_disk()
    with not_raises(
        (FileNotFoundError, ),
            f"The path {path} doesn't exist, it should've been created by write_to_disk.",
    ):
        assert pathlib.Path(path).read_text() == version_string
        os.remove(path)