mirror of
https://github.com/lilydjwg/nvchecker
synced 2024-12-17 20:24:47 +00:00
Add launchpad source
This commit is contained in:
parent
61ca3c95d0
commit
5677c9595e
20
nvchecker_source/launchpad.py
Normal file
20
nvchecker_source/launchpad.py
Normal file
@ -0,0 +1,20 @@
|
||||
# MIT Licensed
|
||||
# Copyright (c) 2024 Bert Peters <bertptrs@archlinux.org>, et al.
|
||||
from __future__ import annotations
|
||||
from nvchecker.api import AsyncCache, Entry, RichResult
|
||||
|
||||
PROJECT_INFO_URL = "https://api.launchpad.net/1.0/{launchpad}"
|
||||
|
||||
async def get_version(name: str, conf: Entry, *, cache: AsyncCache, **kwargs):
|
||||
launchpad = conf["launchpad"]
|
||||
|
||||
project_data = await cache.get_json(PROJECT_INFO_URL.format(launchpad=launchpad))
|
||||
data = await cache.get_json(project_data['releases_collection_link'])
|
||||
|
||||
return [
|
||||
RichResult(version=entry["version"], url=entry["web_link"])
|
||||
for entry in data["entries"]
|
||||
]
|
||||
|
||||
|
||||
|
15
tests/test_launchpad.py
Normal file
15
tests/test_launchpad.py
Normal file
@ -0,0 +1,15 @@
|
||||
# MIT Licensed
|
||||
# Copyright (c) 2024 Bert Peters <bertptrs@archlinux.org>, et al.
|
||||
import pytest
|
||||
pytestmark = [pytest.mark.asyncio(scope="session"), pytest.mark.needs_net]
|
||||
|
||||
async def test_launchpad(get_version):
|
||||
version = await get_version(
|
||||
"sakura",
|
||||
{
|
||||
"source": "launchpad",
|
||||
"launchpad": "sakura",
|
||||
}
|
||||
)
|
||||
|
||||
assert version == '3.8.7'
|
Loading…
Reference in New Issue
Block a user