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

chore: backport unixsocket -> unixsocket2 to 1.25 for charmcraft #857

Merged
merged 5 commits into from
Oct 3, 2024
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
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.25.2
current_version = 1.25.3
commit = True
tag = True

Expand Down
2 changes: 1 addition & 1 deletion craft_parts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

"""Craft a project from several parts."""

__version__ = "1.25.2"
__version__ = "1.25.3"

from . import plugins
from .actions import Action, ActionProperties, ActionType
Expand Down
6 changes: 6 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
Changelog
*********

1.25.3 (2024-09-27)
-------------------

- Replace requests-unixsocket with requests-unixsocket2
- Bump minimum Python version to 3.8 (required for requests-unixsocket2)

1.25.2 (2023-10-24)
-------------------

Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
author = "Canonical Ltd."

# The full version, including alpha/beta/rc tags
release = "1.25.2"
release = "1.25.3"

# Open Graph configuration - defines what is displayed in the website preview
ogp_site_url = "https://canonical-craft-parts.readthedocs-hosted.com"
Expand Down
7 changes: 3 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

from setuptools import find_packages, setup # type: ignore

VERSION = "1.25.2"
VERSION = "1.25.3"

with open("README.md") as readme_file:
readme = readme_file.read()
Expand Down Expand Up @@ -50,9 +50,8 @@ def is_rtd() -> bool:
"pydantic>=1.9.0,<2.0.0",
"pydantic-yaml[pyyaml]>=0.11.0,<1.0.0",
"pyxdg",
"requests<2.32",
"requests-unixsocket",
"urllib3<2", # keep compatible API
"requests",
"requests-unixsocket2",
]

dev_requires = [
Expand Down
6 changes: 6 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ def new_dir(monkeypatch, tmpdir):
yield tmpdir


@pytest.fixture
def new_path(monkeypatch, tmp_path):
monkeypatch.chdir(tmp_path)
return tmp_path


@pytest.fixture
def mock_chdir(monkeypatch):
mock_fn = mock.Mock(spec=os.chdir)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

# Allow redefinition in order to include parent tests below.
# mypy: disable-error-code="no-redef"
# pyright: reportAssignmentType=warning
import pathlib
import textwrap

Expand Down
58 changes: 58 additions & 0 deletions tests/integration/packages/test_snaps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*-
#
# Copyright 2024 Canonical Ltd.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License version 3 as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""Integration tests for interacting with snapd."""

import pathlib
from typing import Sequence

import pytest
import pytest_check # type: ignore[import]

from craft_parts.packages import snaps


def test_get_installed_snaps_success():
"""Test that get_installed_snaps returns a list of snaps."""
actual = snaps.get_installed_snaps()

for snap in actual:
name, _, revision = snap.partition("=")
pytest_check.is_true(len(name) >= 1)
if revision.startswith("x"):
# Locally installed snaps should be of the form "x<int>"
with pytest_check.check():
int(revision[1:])
else:
# Store-instaled snaps should simply have an integer revision.
with pytest_check.check():
int(revision)


@pytest.mark.parametrize(
"snaps_list",
[
{"snapcraft", "ruff"},
{"snapcraft/7.x/stable"},
],
)
def test_download_snaps_success(new_path: pathlib.Path, snaps_list: Sequence[str]):

snaps.download_snaps(snaps_list=snaps_list, directory=str(new_path))

for snap in snaps_list:
snap_name, _, snap_channel = snap.partition("/")
assert len(list(new_path.glob(f"{snap_name}*.snap"))) == 1
assert len(list(new_path.glob(f"{snap_name}*.assert"))) == 1
Loading