# Path: eldonationtracker/utils/update_available.py
# def update_available(pypi_version: str, current_version: str) -> bool:
#     """Use semver module to calculate whether there is a newer version on PyPi.
# 
#     :return: True if the PyPi version is higher than the version being run.\
#     Returns false if the version being compared to PyPi is equal or greater\
#     than the PyPi version."""
#     if semver.compare(pypi_version, current_version) == 1:
#         update_log.info(f"There is an update available. PyPi version: {pypi_version}")
#         return True
#     else:
#         update_log.info("You have the latest version.")
#         return False


from unittest import mock
from eldonationtracker.utils import update_available


fake_py_pi_json = {"info": {"version": "4.4.4"}}
fake_url_json_load = mock.Mock()
fake_url_json_load.return_value = fake_py_pi_json


@mock.patch.object(update_available.json, "load", fake_url_json_load)
def test_get_pypi_version():
    version = update_available.get_pypi_version("https://pypi.org/pypi/eldonationtracker/json")
    assert version == "4.4.4"


def test_get_pypi_version_exception():
    version = update_available.get_pypi_version("https://pypi.org/pypi/eldonationtracker_wrong/json")
    assert version == "Error"



# Path: eldonationtracker/utils/update_available.py
# def update_available(pypi_version: str, current_version: str) -> bool:
#     """Use semver module to calculate whether there is a newer version on PyPi.
# 
#     :return: True if the PyPi version is higher than the version being run.\
#     Returns false if the version being compared to PyPi is equal or greater\
#     than the PyPi version."""
#     if semver.compare(pypi_version, current_version) == 1:
#         update_log.info(f"There is an update available. PyPi version: {pypi_version}")
#         return True
#     else:
#         update_log.info("You have the latest version.")
#         return False


# Path: eldonationtracker/utils/tests/test_update_available.py
from unittest import mock
from eldonationtracker.utils import update_available



fake_py_pi_json = {"info": {"version": "4.4.4"}}
fake_url_json_load = mock.Mock()
fake_url_json_load.return_value = fake_py_pi_json


@mock.patch.object(update_available.json, "load", fake_url_json_load)
def test_get_pypi_version():
    version = update_available.get_pypi_version("https://pypi.org/pypi/eldonationtracker/json")
    assert version == "4.4.4"


def test_get_pypi_version_exception():
    version = update_available.get_pypi_version("https://pypi.org/pypi/eldonationtracker_wrong/json")
    assert version == "Error"



def test_local_major_version_old():