Skip to content

Commit

Permalink
Fix version tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MasloMaslane committed Apr 4, 2024
1 parent 0ce9fac commit 8075949
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +52,27 @@ 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"}})
def create_response(version):
return {"releases": {version: "something"}}

mocker.get("https://pypi.python.org/pypi/sinol-make/json", json=create_response("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"}})
mocker.get("https://pypi.python.org/pypi/sinol-make/json", json=create_response("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"}})
mocker.get("https://pypi.python.org/pypi/sinol-make/json", json=create_response("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"}})
mocker.get("https://pypi.python.org/pypi/sinol-make/json", json=create_response("1.0.1"))
util.check_version()
version = util.check_for_updates("1.0.0", False)
assert version == "1.0.1"
Expand All @@ -86,7 +89,7 @@ def test_check_version(**kwargs):
version_file.unlink()

# Test correct request
mocker.get("https://pypi.python.org/pypi/sinol-make/json", json={"info": {"version": "1.0.0"}})
mocker.get("https://pypi.python.org/pypi/sinol-make/json", json=create_response(("1.0.0")))
util.check_version()
assert version_file.is_file()
assert version_file.read_text() == "1.0.0"
Expand Down

0 comments on commit 8075949

Please sign in to comment.