Skip to content
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
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[build-system]
# Use uv's PEP 517 build backend for fast, reproducible builds
build-backend = "uv_build"
requires = ["uv-build<0.12"]
requires = ["uv-build<0.13"]

[project]
name = "watchmaker"
Expand Down Expand Up @@ -94,6 +94,7 @@ exclude = [
[tool.ruff.lint]
ignore = [
"B905", # zip() without strict= - requires Python 3.10+, project supports 3.8+
"CPY001", # Global ignore for copyright-header enforcement
"D107", # __init__ docstrings are documented at the class level to avoid duplication
"D203", # Conflicts with D211 (no-blank-line-before-class). Project uses D211 style.
"D212", # Conflicts with D213 (multi-line-summary-first-line). Project uses D213 style.
Expand Down
2 changes: 1 addition & 1 deletion requirements/basics.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# The PEP 517 backend is defined in pyproject.toml [build-system] and will be
# resolved automatically by the frontend. We also pin it here for reproducibility
# in environments that choose to invoke the backend directly.
uv==0.11.29
uv==0.12.2
2 changes: 1 addition & 1 deletion requirements/build.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
boto3==1.43.51
boto3==1.43.66
pyinstaller==6.21.0
4 changes: 2 additions & 2 deletions requirements/check.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ruff==0.15.22
twine==6.2.0
ruff==0.16.1
twine==7.0.0
181 changes: 91 additions & 90 deletions tests/test_saltworker.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,104 +635,105 @@ def test_linux_salt_content_none(
sys.version_info < (3, 4),
reason="Not supported in this Python version.",
)
@patch("pathlib.Path.open", autospec=True)
@patch("os.walk", autospec=True)
@patch("yaml.safe_dump", autospec=True)
@patch("yaml.safe_load", autospec=True)
@patch("watchmaker.utils.copytree", autospec=True)
@patch("glob.glob", autospec=True)
@patch("watchmaker.utils.copy_subdirectories", autospec=True)
def test_linux_salt_content_path_none(
mock_copysubdirs,
mock_glob,
mock_copytree,
mock_yload,
mock_ydump,
mock_os,
mock_open,
):
def test_linux_salt_content_path_none():
"""Test that Pythonic None can be used without error rather than 'None'."""
# setup ========================
system_params = {}
salt_config = {}
system_params["prepdir"] = Path("4504257a-76d0-49bd-9d04-53c1459b7156")
system_params["logdir"] = Path("045143d6-0e87-497f-a11a-5eebb1ec7edf")
system_params["workingdir"] = Path("83f16e7b-c2cf-482b-93c8-32a558f6ded6")

salt_config["salt_content"] = "33691f8e-e245-4be2-827b-2fa727600fb4.zip"
salt_config["salt_content_path"] = None

# execution ====================
saltworker_lx = SaltLinux(system_params, **salt_config)
saltworker_lx.working_dir = system_params["workingdir"]

saltworker_lx.retrieve_file = MagicMock(return_value=None)
saltworker_lx.extract_contents = MagicMock(return_value=None)

saltworker_lx._build_salt_formula("e8d7398e-49fa-4eb9-8f8b-22c9d3fdb7f7")

# assertions ===================
assert saltworker_lx.retrieve_file.call_count == 1
assert saltworker_lx.extract_contents.call_count == 1
assert mock_copysubdirs.call_count == 1
assert mock_open.call_count == 1
assert mock_os.call_count == 1
assert mock_ydump.call_count == 1
assert mock_yload.call_count == 1
assert mock_copytree.call_count > 1
assert mock_glob.call_count == 0
with patch("pathlib.Path.open", autospec=True) as mock_open, patch(
"os.walk",
autospec=True,
) as mock_os, patch("yaml.safe_dump", autospec=True) as mock_ydump, patch(
"yaml.safe_load",
autospec=True,
) as mock_yload, patch(
"watchmaker.utils.copytree",
autospec=True,
) as mock_copytree, patch(
"glob.glob",
autospec=True,
) as mock_glob, patch(
"watchmaker.utils.copy_subdirectories",
autospec=True,
) as mock_copysubdirs:
# setup ========================
system_params = {}
salt_config = {}
system_params["prepdir"] = Path("4504257a-76d0-49bd-9d04-53c1459b7156")
system_params["logdir"] = Path("045143d6-0e87-497f-a11a-5eebb1ec7edf")
system_params["workingdir"] = Path("83f16e7b-c2cf-482b-93c8-32a558f6ded6")

salt_config["salt_content"] = "33691f8e-e245-4be2-827b-2fa727600fb4.zip"
salt_config["salt_content_path"] = None

# execution ====================
saltworker_lx = SaltLinux(system_params, **salt_config)
saltworker_lx.working_dir = system_params["workingdir"]

saltworker_lx.retrieve_file = MagicMock(return_value=None)
saltworker_lx.extract_contents = MagicMock(return_value=None)

saltworker_lx._build_salt_formula("e8d7398e-49fa-4eb9-8f8b-22c9d3fdb7f7")

# assertions ===================
assert saltworker_lx.retrieve_file.call_count == 1
assert saltworker_lx.extract_contents.call_count == 1
assert mock_copysubdirs.call_count == 1
assert mock_open.call_count == 1
assert mock_os.call_count == 1
assert mock_ydump.call_count == 1
assert mock_yload.call_count == 1
assert mock_copytree.call_count > 1
assert mock_glob.call_count == 0


@pytest.mark.skipif(
sys.version_info < (3, 4),
reason="Not supported in this Python version.",
)
@patch("pathlib.Path.open", autospec=True)
@patch("os.walk", autospec=True)
@patch("yaml.safe_dump", autospec=True)
@patch("yaml.safe_load", autospec=True)
@patch("watchmaker.utils.copytree", autospec=True)
@patch("pathlib.Path.glob", autospec=True)
def test_linux_salt_content_path(
mock_glob,
mock_copytree,
mock_yload,
mock_ydump,
mock_os,
mock_open,
):
def test_linux_salt_content_path():
"""Ensure that files from salt_content_path are retrieved correctly."""
# setup ========================
system_params = {}
salt_config = {}
system_params["prepdir"] = Path("96003f32-5808-4ef8-a573-763b7f47ba9d")
system_params["logdir"] = Path("0585f9d7-ed0e-4a1b-ac0d-2b10a245a0eb")
system_params["workingdir"] = Path("35f411db-355b-4953-ae31-d6f592753e58")

salt_config["salt_content"] = "d002be6e-645d-4f58-97c9-8335df0ff5e4.zip"
salt_config["salt_content_path"] = "05628e08-f1be-474d-8c12-5bb6517fc5f9"

# execution ====================
saltworker_lx = SaltLinux(system_params, **salt_config)

saltworker_lx.retrieve_file = MagicMock(return_value=None)
saltworker_lx.extract_contents = MagicMock(return_value=None)
saltworker_lx.working_dir = system_params["workingdir"]
mock_glob.return_value = (
p for p in [Path("05628e08-f1be-474d-8c12-5bb6517fc5f9/87a2324d")]
)

saltworker_lx._build_salt_formula("8822e968-deea-410f-9b6e-d25a36c512d1")

# assertions ===================
assert saltworker_lx.retrieve_file.call_count == 1
assert saltworker_lx.extract_contents.call_count == 1
assert mock_open.call_count == 1
assert mock_os.call_count == 3
assert mock_ydump.call_count == 1
assert mock_yload.call_count == 1
assert mock_copytree.call_count > 1
assert mock_glob.call_count == 1
with patch("pathlib.Path.open", autospec=True) as mock_open, patch(
"os.walk",
autospec=True,
) as mock_os, patch("yaml.safe_dump", autospec=True) as mock_ydump, patch(
"yaml.safe_load",
autospec=True,
) as mock_yload, patch(
"watchmaker.utils.copytree",
autospec=True,
) as mock_copytree, patch(
"pathlib.Path.glob",
autospec=True,
) as mock_glob:
# setup ========================
system_params = {}
salt_config = {}
system_params["prepdir"] = Path("96003f32-5808-4ef8-a573-763b7f47ba9d")
system_params["logdir"] = Path("0585f9d7-ed0e-4a1b-ac0d-2b10a245a0eb")
system_params["workingdir"] = Path("35f411db-355b-4953-ae31-d6f592753e58")

salt_config["salt_content"] = "d002be6e-645d-4f58-97c9-8335df0ff5e4.zip"
salt_config["salt_content_path"] = "05628e08-f1be-474d-8c12-5bb6517fc5f9"

# execution ====================
saltworker_lx = SaltLinux(system_params, **salt_config)

saltworker_lx.retrieve_file = MagicMock(return_value=None)
saltworker_lx.extract_contents = MagicMock(return_value=None)
saltworker_lx.working_dir = system_params["workingdir"]
mock_glob.return_value = (
p for p in [Path("05628e08-f1be-474d-8c12-5bb6517fc5f9/87a2324d")]
)

saltworker_lx._build_salt_formula("8822e968-deea-410f-9b6e-d25a36c512d1")

# assertions ===================
assert saltworker_lx.retrieve_file.call_count == 1
assert saltworker_lx.extract_contents.call_count == 1
assert mock_open.call_count == 1
assert mock_os.call_count >= 1
assert mock_ydump.call_count == 1
assert mock_yload.call_count == 1
assert mock_copytree.call_count > 1
assert mock_glob.call_count == 1


def test_linux_ou_path_none():
Expand Down