From 8075949a2b4c1b192b90d160e2ddd6e432767582 Mon Sep 17 00:00:00 2001 From: Mateusz Masiarz Date: Fri, 5 Apr 2024 00:02:31 +0200 Subject: [PATCH] Fix version tests --- tests/test_util.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/test_util.py b/tests/test_util.py index 592020a4..3d259fab 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -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" @@ -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"