Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from aiohttp.client import ClientSession
from aiohttp.client_exceptions import ClientConnectionError, ClientError
from common_library.json_serialization import json_dumps
from packaging.version import Version
from servicelib.aiohttp.client_session import get_client_session
from tenacity.asyncio import AsyncRetrying
from tenacity.before import before_log
Expand Down Expand Up @@ -93,6 +94,11 @@ async def create_cached_indexes(app: web.Application) -> None:
app[APP_FRONTEND_CACHED_INDEXES_KEY] = cached_indexes


def _get_release_notes_vtag(vtag: str) -> str:
version = Version(vtag)
return f"v{version.major}.{version.minor}.0"


async def create_and_cache_statics_json(app: web.Application) -> None:
# NOTE: in devel model, the folder might be under construction
# (qx-compile takes time), therefore we create statics.json
Expand Down Expand Up @@ -132,7 +138,8 @@ async def create_and_cache_statics_json(app: web.Application) -> None:
):
# template URL should be somethign like:
# https://github.com/ITISFoundation/osparc-issues/blob/master/release-notes/osparc/{vtag}.md
data["vcsReleaseUrl"] = template_url.format(vtag=vtag)
release_vtag = _get_release_notes_vtag(vtag)
data["vcsReleaseUrl"] = template_url.format(vtag=release_vtag)

data_json = json_dumps(data)
_logger.debug("Front-end statics.json: %s", data_json)
Expand Down
17 changes: 16 additions & 1 deletion services/web/server/tests/unit/with_dbs/01/test_statics.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
from simcore_service_webserver.statics._constants import (
APP_FRONTEND_CACHED_STATICS_JSON_KEY,
)
from simcore_service_webserver.statics._events import create_and_cache_statics_json
from simcore_service_webserver.statics._events import (
_get_release_notes_vtag,
create_and_cache_statics_json,
)
from simcore_service_webserver.statics.plugin import setup_statics


Expand Down Expand Up @@ -154,3 +157,15 @@ async def test_create_and_cache_statics_json_vendor_vcs_overwrite(
product_dict = json.loads(product_data)
assert product_dict.get("vcsReleaseTag") == vcs_release_tag
assert product_dict.get("vcsReleaseUrl") == expected_vcs_url


@pytest.mark.parametrize(
"vtag, expected_vtag",
[
("v1.11.34", "v1.11.0"),
("v1.11.8", "v1.11.0"),
("v1.11.0", "v1.11.0"),
],
)
def test__get_release_notes_vtag(vtag: str, expected_vtag: str):
assert _get_release_notes_vtag(vtag) == expected_vtag
Loading