Files
RaptDramaDump/tests/test_updater.py
T

35 lines
1.3 KiB
Python

from server.services.updater import describe_release, is_newer, public_notes
def test_version_order_and_public_notes() -> None:
assert is_newer("0.1.1", "0.1.0")
assert is_newer("v0.2.0", "0.1.9")
assert not is_newer("0.1.0", "0.1.0")
assert not is_newer("0.1.0", "0.1.1")
assert "http" not in public_notes("修复播放。\n详情 https://example.com/repo/releases/1")
def test_release_needs_the_package_asset() -> None:
current = "0.1.0"
missing = describe_release({"tag_name": "v0.1.1", "body": "更新", "assets": []}, current)
assert missing is None
found = describe_release(
{
"tag_name": "v0.1.1",
"body": "打开时提示更新。 https://example.com/hidden",
"assets": [{"name": "VideosDownTools-windows-x64.zip", "browser_download_url": "https://example.com/app.zip"}],
},
current,
)
assert found is not None
assert found["latest"] == "0.1.1"
assert "http" not in found["notes"]
assert found["url"].endswith(".zip")
assert describe_release({"tag_name": "v0.1.0", "assets": [{"name": "VideosDownTools-windows-x64.zip", "browser_download_url": "https://example.com/app.zip"}]}, current) is None
if __name__ == "__main__":
test_version_order_and_public_notes()
test_release_needs_the_package_asset()
print("ok")