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

util: replace os_release.py with distro package #59

Merged
merged 1 commit into from
May 22, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
95 changes: 0 additions & 95 deletions craft_archives/os_release.py

This file was deleted.

8 changes: 5 additions & 3 deletions craft_archives/repo/apt_sources_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
from pathlib import Path
from typing import List, Optional, cast

from craft_archives import os_release, utils
import distro

from craft_archives import utils

from . import apt_key_manager, apt_ppa, apt_uca, errors, package_repository

Expand Down Expand Up @@ -194,7 +196,7 @@ def _install_sources_ppa(
:returns: True if source configuration was changed.
"""
owner, name = apt_ppa.split_ppa_parts(ppa=package_repo.ppa)
codename = os_release.OsRelease().version_codename()
codename = distro.codename()

key_id = apt_ppa.get_launchpad_ppa_key_id(ppa=package_repo.ppa)
keyring_path = apt_key_manager.get_keyring_path(
Expand Down Expand Up @@ -226,7 +228,7 @@ def _install_sources_uca(
cloud = package_repo.cloud
pocket = package_repo.pocket

codename = os_release.OsRelease().version_codename()
codename = distro.codename()
apt_uca.check_release_compatibility(codename, cloud, pocket)

key_id = package_repository.UCA_KEY_ID
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name = "craft-archives"
version = "0.0.4"
readme = "README.rst"
dependencies = [
"distro>=1.3.0",
"gnupg",
"launchpadlib",
"lazr.restfulclient",
Expand Down
5 changes: 3 additions & 2 deletions tests/integration/repo/test_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
from textwrap import dedent
from typing import Any, Dict, List

import distro
import pytest
from craft_archives import os_release, repo
from craft_archives import repo

APT_SOURCES = dedent(
"""
Expand All @@ -35,7 +36,7 @@
"""
).lstrip()

VERSION_CODENAME = os_release.OsRelease().version_codename()
VERSION_CODENAME = distro.codename()

PPA_SOURCES = dedent(
"""
Expand Down
11 changes: 6 additions & 5 deletions tests/unit/repo/test_apt_sources_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
import http
import urllib.error
from textwrap import dedent
from unittest import mock
from unittest.mock import call, patch

import distro
import pytest
from craft_archives.repo import apt_ppa, apt_sources_manager, errors
from craft_archives.repo.package_repository import (
Expand Down Expand Up @@ -59,11 +61,10 @@ def mock_run(mocker):


@pytest.fixture(autouse=True)
def mock_version_codename(mocker):
yield mocker.patch(
"craft_archives.os_release.OsRelease.version_codename",
return_value="FAKE-CODENAME",
)
def mock_version_codename(monkeypatch):
mock_codename = mock.Mock(return_value="FAKE-CODENAME")
monkeypatch.setattr(distro, "codename", mock_codename)
yield mock_codename


@pytest.fixture
Expand Down