Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MasloMaslane committed Apr 4, 2024
1 parent 9bc7c8f commit 6a10cbf
Showing 1 changed file with 23 additions and 22 deletions.
45 changes: 23 additions & 22 deletions tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,6 @@ def test_file_diff():
assert util.file_diff(a_file, b_file) is False


def test_compare_versions():
"""
Tests for compare_versions function
"""

assert util.compare_versions('1.0.0', '1.0.0') == 0
assert util.compare_versions('1.0.0', '1.0.1') == -1
assert util.compare_versions('1.0.1', '1.0.0') == 1
assert util.compare_versions('1.0.0', '1.1.0') == -1
assert util.compare_versions('1.1.0', '1.0.0') == 1
assert util.compare_versions('1.0.0', '2.0.0') == -1
assert util.compare_versions('2.0.0', '1.0.0') == 1
with pytest.raises(ValueError):
util.compare_versions('1.0.0', '')
with pytest.raises(ValueError):
util.compare_versions('', '1.0.0')
with pytest.raises(ValueError):
util.compare_versions('1.0.0', 'abc')
with pytest.raises(ValueError):
util.compare_versions('abc', '1.0.0')


@requests_mock.Mocker(kw="mocker")
def test_check_version(**kwargs):
"""
Expand All @@ -74,6 +52,29 @@ def test_check_version(**kwargs):
"""
mocker = kwargs["mocker"]

mocker.get("https://pypi.python.org/pypi/sinol-make/json", json={"info": {"version": "1.0.0.dev2"}})
util.check_version()
version = util.check_for_updates("1.0.0.dev1", False)
assert version == "1.0.0.dev2"
assert util.is_dev(version)

mocker.get("https://pypi.python.org/pypi/sinol-make/json", json={"info": {"version": "1.0.0"}})
util.check_version()
version = util.check_for_updates("1.0.0.dev1", False)
assert version == "1.0.0"
assert not util.is_dev(version)

mocker.get("https://pypi.python.org/pypi/sinol-make/json", json={"info": {"version": "2.0.0.dev1"}})
util.check_version()
version = util.check_for_updates("1.0.0", False)
assert version is None

mocker.get("https://pypi.python.org/pypi/sinol-make/json", json={"info": {"version": "1.0.1"}})
util.check_version()
version = util.check_for_updates("1.0.0", False)
assert version == "1.0.1"
assert not util.is_dev(version)

importlib = util.import_importlib_resources()

data_dir = importlib.files('sinol_make').joinpath("data")
Expand Down

0 comments on commit 6a10cbf

Please sign in to comment.