Download the latest asset from Github

This commit is contained in:
Stanislas Jouffroy 2025-03-03 22:58:12 +01:00
parent c32449e465
commit b56d8e72ca
11 changed files with 283 additions and 2 deletions

0
tests/__init__.py Normal file
View file

47
tests/conftest.py Normal file
View file

@ -0,0 +1,47 @@
import pytest
from majordome.github_service import GithubConnector
from majordome.settings import GithubSettings
from majordome.software_repo import SoftwareRepo
github_settings = GithubSettings()
@pytest.fixture
def github_token():
return github_settings.token
@pytest.fixture
def project_url():
return "https://github.com/FreeTubeApp/FreeTube"
@pytest.fixture
def github_connector(github_token):
return GithubConnector(github_token)
@pytest.fixture
def freetube_tag_name_mnemonic():
return "v{{VERSION}}-beta"
@pytest.fixture
def freetube_amd64_deb_mnemonic():
return "freetube_{{VERSION}}_amd64.deb"
@pytest.fixture
def freetube_repo(
project_url,
github_connector,
freetube_tag_name_mnemonic,
freetube_amd64_deb_mnemonic,
):
return SoftwareRepo(
project_url,
github_connector,
freetube_tag_name_mnemonic,
freetube_amd64_deb_mnemonic,
)

View file

@ -0,0 +1,22 @@
from pathlib import Path
def test_get_latest_version(freetube_repo):
version = freetube_repo.get_latest_version()
assert version == "0.23.2"
def test_latest_amd_64_deb_asset(freetube_repo):
asset_name = freetube_repo.get_latest_asset_id()
assert asset_name == 231868075
def test_download_latest_asset(freetube_repo):
asset_bytes = freetube_repo.download_latest_asset()
assert (
asset_bytes
== Path("/home/stan/Téléchargements/freetube_0.23.2_amd64.deb").read_bytes()
)