From a73863f5666b9469e48bca82efc7de4ea24bf7d4 Mon Sep 17 00:00:00 2001 From: Paul Spooren Date: Tue, 27 Apr 2021 00:11:13 +0200 Subject: [PATCH] api: show latest version of all branches Not only show latest stable branches but the latest version for every branch supported. Clients should figure out on their own if an upgrade is required. * Stable releases don't require an upgrade to the same stable release * Release SNAPSHOTS can be upgraded to release SNAPSHOTS ,RCs or release * SNAPSHOTS only upgrade to SNAPSHOTS Signed-off-by: Paul Spooren --- asu/api.py | 5 +---- tests/conftest.py | 2 +- tests/test_api.py | 4 +++- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/asu/api.py b/asu/api.py index bd6b9368..a7d18220 100644 --- a/asu/api.py +++ b/asu/api.py @@ -46,10 +46,7 @@ def get_latest() -> dict: lambda b: b["versions"][0], filter( lambda b: b.get("enabled"), - filter( - lambda b: not b.get("snapshot"), - current_app.config["BRANCHES"], - ), + current_app.config["BRANCHES"], ), ) ) diff --git a/tests/conftest.py b/tests/conftest.py index 021512c4..464d2f02 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -83,7 +83,7 @@ def app(redis): { "name": "19.07", "enabled": True, - "versions": ["19.07.6", "19.07.5"], + "versions": ["19.07.7", "19.07.6"], "git_branch": "openwrt-19.07", "path": "releases/{version}", "path_packages": "releases/packages-{branch}", diff --git a/tests/test_api.py b/tests/test_api.py index aa189377..0db9ebc3 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -24,7 +24,9 @@ def test_api_build(client): def test_api_latest_default(client): response = client.get("/api/latest") - assert response.json == {"latest": ["19.07.6"]} + assert "19.07.7" in response.json["latest"] + assert "21.02.0-rc1" in response.json["latest"] + assert "SNAPSHOT" in response.json["latest"] assert response.status == "200 OK"