Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix no changelog API response #5064

Merged
merged 3 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 2 additions & 1 deletion supervisor/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,6 @@ def _register_store(self) -> None:
web.get("/store", api_store.store_info),
web.get("/store/addons", api_store.addons_list),
web.get("/store/addons/{addon}", api_store.addons_addon_info),
web.get("/store/addons/{addon}/{version}", api_store.addons_addon_info),
web.get("/store/addons/{addon}/icon", api_store.addons_addon_icon),
web.get("/store/addons/{addon}/logo", api_store.addons_addon_logo),
web.get(
Expand All @@ -719,6 +718,8 @@ def _register_store(self) -> None:
"/store/addons/{addon}/update/{version}",
api_store.addons_addon_update,
),
# Must be below others since it has a wildcard in resource path
web.get("/store/addons/{addon}/{version}", api_store.addons_addon_info),
web.post("/store/reload", api_store.reload),
web.get("/store/repositories", api_store.repositories_list),
web.get(
Expand Down
2 changes: 1 addition & 1 deletion supervisor/api/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ async def addons_addon_changelog(self, request: web.Request) -> str:
"""Return changelog from add-on."""
addon = self._extract_addon(request)
if not addon.with_changelog:
raise APIError(f"No changelog found for add-on {addon.slug}!")
return f"No changelog found for add-on {addon.slug}!"

with addon.path_changelog.open("r") as changelog:
return changelog.read()
Expand Down
11 changes: 11 additions & 0 deletions tests/api/test_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,14 @@ async def container_events_task(*args, **kwargs):
assert resp.status == 200

await _container_events_task


@pytest.mark.parametrize("resource", ["store/addons", "addons"])
async def test_api_store_addons_no_changelog(
api_client: TestClient, coresys: CoreSys, store_addon: AddonStore, resource: str
):
"""Test /store/addons/{addon}/changelog REST API."""
sairon marked this conversation as resolved.
Show resolved Hide resolved
resp = await api_client.get(f"/{resource}/{store_addon.slug}/changelog")
assert resp.status == 200
agners marked this conversation as resolved.
Show resolved Hide resolved
result = await resp.text()
assert result == "No changelog found for add-on test_store_addon!"
Loading