Track upstream discovery state
This commit is contained in:
parent
928c7841c3
commit
0d9148e336
5 changed files with 945 additions and 165 deletions
|
|
@ -296,10 +296,20 @@ class TestValidatePackageInfo:
|
|||
monkeypatch.setattr(
|
||||
debian_todo,
|
||||
"load_source_info_map",
|
||||
lambda: {"mypkg": {"vcs_git": "python-team", "uploaders": ""}},
|
||||
lambda: {
|
||||
"mypkg": {
|
||||
"team": "python-team",
|
||||
"vcs_git": "https://salsa.debian.org/python-team/deps/mypkg.git",
|
||||
"uploaders": "",
|
||||
}
|
||||
},
|
||||
)
|
||||
result = debian_todo.validate_package_info("mypkg")
|
||||
assert result == {"vcs_git": "python-team", "uploaders": ""}
|
||||
assert result == {
|
||||
"team": "python-team",
|
||||
"vcs_git": "https://salsa.debian.org/python-team/deps/mypkg.git",
|
||||
"uploaders": "",
|
||||
}
|
||||
|
||||
def test_package_not_found(self, monkeypatch):
|
||||
"""Test package not in source info map."""
|
||||
|
|
@ -313,7 +323,7 @@ class TestValidatePackageInfo:
|
|||
monkeypatch.setattr(
|
||||
debian_todo,
|
||||
"load_source_info_map",
|
||||
lambda: {"mypkg": {"vcs_git": "", "uploaders": ""}},
|
||||
lambda: {"mypkg": {"team": "", "vcs_git": "", "uploaders": ""}},
|
||||
)
|
||||
with pytest.raises(debian_todo.PackageNotFoundError) as exc_info:
|
||||
debian_todo.validate_package_info("mypkg")
|
||||
|
|
@ -326,7 +336,11 @@ class TestResolvePackageDirectories:
|
|||
def test_python_team_package(self, tmp_path, monkeypatch):
|
||||
"""Test resolving directories for python-team package."""
|
||||
monkeypatch.setattr(debian_todo, "DEBIAN_SRC_BASE", tmp_path)
|
||||
source_info = {"vcs_git": "python-team", "uploaders": ""}
|
||||
source_info = {
|
||||
"team": "python-team",
|
||||
"vcs_git": "https://salsa.debian.org/python-team/deps/mypkg.git",
|
||||
"uploaders": "",
|
||||
}
|
||||
team_dir, pkg_dir, repo_dir = debian_todo.resolve_package_directories(
|
||||
"mypkg", source_info
|
||||
)
|
||||
|
|
@ -337,7 +351,11 @@ class TestResolvePackageDirectories:
|
|||
def test_homeassistant_team_package(self, tmp_path, monkeypatch):
|
||||
"""Test resolving directories for homeassistant-team package."""
|
||||
monkeypatch.setattr(debian_todo, "DEBIAN_SRC_BASE", tmp_path)
|
||||
source_info = {"vcs_git": "homeassistant-team", "uploaders": ""}
|
||||
source_info = {
|
||||
"team": "homeassistant-team",
|
||||
"vcs_git": "https://salsa.debian.org/homeassistant-team/deps/ha-pkg.git",
|
||||
"uploaders": "",
|
||||
}
|
||||
team_dir, pkg_dir, repo_dir = debian_todo.resolve_package_directories(
|
||||
"ha-pkg", source_info
|
||||
)
|
||||
|
|
@ -352,7 +370,11 @@ class TestEnsurePackageCheckout:
|
|||
def test_successful_checkout(self, tmp_path):
|
||||
"""Test successful package checkout."""
|
||||
pkg_dir = tmp_path / "python" / "mypkg"
|
||||
source_info = {"vcs_git": "python-team", "uploaders": ""}
|
||||
source_info = {
|
||||
"team": "python-team",
|
||||
"vcs_git": "https://salsa.debian.org/python-team/deps/mypkg.git",
|
||||
"uploaders": "",
|
||||
}
|
||||
|
||||
with patch("debian_todo.run_command") as mock_run:
|
||||
debian_todo.ensure_package_checkout("mypkg", source_info, pkg_dir)
|
||||
|
|
@ -367,7 +389,11 @@ class TestEnsurePackageCheckout:
|
|||
"""Test checkout when parent directory already exists."""
|
||||
pkg_dir = tmp_path / "python" / "mypkg"
|
||||
pkg_dir.mkdir(parents=True)
|
||||
source_info = {"vcs_git": "python-team", "uploaders": ""}
|
||||
source_info = {
|
||||
"team": "python-team",
|
||||
"vcs_git": "https://salsa.debian.org/python-team/deps/mypkg.git",
|
||||
"uploaders": "",
|
||||
}
|
||||
|
||||
with patch("debian_todo.run_command") as mock_run:
|
||||
debian_todo.ensure_package_checkout("mypkg", source_info, pkg_dir)
|
||||
|
|
@ -399,7 +425,10 @@ class TestRunGbpPqWorkflow:
|
|||
"""Test successful gbp pq import and switch."""
|
||||
with patch("debian_todo.run_command") as mock_run:
|
||||
debian_todo.run_gbp_pq_workflow(tmp_path)
|
||||
assert mock_run.call_count == 2
|
||||
assert mock_run.call_count == 3
|
||||
mock_run.assert_any_call(
|
||||
["gbp", "pq", "drop"], tmp_path, "Import patch queue"
|
||||
)
|
||||
mock_run.assert_any_call(
|
||||
["gbp", "pq", "import"], tmp_path, "Import patch queue"
|
||||
)
|
||||
|
|
@ -446,16 +475,12 @@ class TestRunPackageUpdates:
|
|||
"""Tests for run_package_updates function."""
|
||||
|
||||
def test_runs_all_updates(self, tmp_path):
|
||||
"""Test that all update functions are called."""
|
||||
with patch("debian_todo.update_debian_control") as mock_control:
|
||||
with patch("debian_todo.update_debian_copyright_year") as mock_copyright:
|
||||
with patch("debian_todo.update_debian_watch") as mock_watch:
|
||||
with patch("debian_todo.add_salsa_ci") as mock_salsa:
|
||||
debian_todo.run_package_updates(tmp_path)
|
||||
mock_control.assert_called_once_with(tmp_path)
|
||||
mock_copyright.assert_called_once_with(tmp_path)
|
||||
mock_watch.assert_called_once_with(tmp_path)
|
||||
mock_salsa.assert_called_once_with(tmp_path)
|
||||
"""Test that the external package update helper is called."""
|
||||
with patch("debian_todo.subprocess.run") as mock_run:
|
||||
debian_todo.run_package_updates(tmp_path)
|
||||
mock_run.assert_called_once_with(
|
||||
["update-debian-package"], check=True, text=True, cwd=tmp_path
|
||||
)
|
||||
|
||||
|
||||
class TestUpdateDebianControl:
|
||||
|
|
@ -491,14 +516,14 @@ class TestUpdateDebianControl:
|
|||
|
||||
# Verify Standards-Version was updated
|
||||
content = control_path.read_text()
|
||||
assert "Standards-Version: 4.7.3" in content
|
||||
assert "Standards-Version: 4.7.4" in content
|
||||
|
||||
def test_no_changes_needed(self, tmp_path):
|
||||
"""Test when no changes are needed."""
|
||||
debian_dir = tmp_path / "debian"
|
||||
debian_dir.mkdir()
|
||||
control_path = debian_dir / "control"
|
||||
control_path.write_text("Source: mypkg\nStandards-Version: 4.7.3\n")
|
||||
control_path.write_text("Source: mypkg\nStandards-Version: 4.7.4\n")
|
||||
|
||||
with patch("debian_todo.run_command") as mock_run:
|
||||
debian_todo.update_debian_control(tmp_path)
|
||||
|
|
@ -736,7 +761,13 @@ class TestUpdatePackage:
|
|||
monkeypatch.setattr(
|
||||
debian_todo,
|
||||
"load_source_info_map",
|
||||
lambda: {"mypkg": {"vcs_git": "python-team", "uploaders": ""}},
|
||||
lambda: {
|
||||
"mypkg": {
|
||||
"team": "python-team",
|
||||
"vcs_git": "https://salsa.debian.org/python-team/deps/mypkg.git",
|
||||
"uploaders": "",
|
||||
}
|
||||
},
|
||||
)
|
||||
monkeypatch.setattr(debian_todo, "DEBIAN_SRC_BASE", tmp_path)
|
||||
|
||||
|
|
@ -761,27 +792,36 @@ class TestUpdatePackage:
|
|||
monkeypatch.setattr(debian_todo.shutil, "which", lambda _: "/usr/bin/tool")
|
||||
|
||||
# Mock the update functions to avoid needing debian/ directory
|
||||
with patch("debian_todo.run_package_updates"):
|
||||
with patch("debian_todo.run_package_updates"), patch(
|
||||
"debian_todo.save_watch_snapshot"
|
||||
):
|
||||
debian_todo.update_package("mypkg")
|
||||
|
||||
# Check salsa checkout was called
|
||||
assert subprocess_calls[0][0] == ["salsa", "checkout", "python-team/deps/mypkg"]
|
||||
# Check gbp pq commands were called
|
||||
assert subprocess_calls[1][0] == ["gbp", "pq", "import"]
|
||||
assert subprocess_calls[2][0] == ["gbp", "pq", "switch"]
|
||||
assert subprocess_calls[1][0] == ["gbp", "pq", "drop"]
|
||||
assert subprocess_calls[2][0] == ["gbp", "pq", "import"]
|
||||
assert subprocess_calls[3][0] == ["gbp", "pq", "switch"]
|
||||
# Check gbp import-orig was called
|
||||
assert subprocess_calls[3][0] == [
|
||||
assert subprocess_calls[4][0] == [
|
||||
"gbp", "import-orig", "--uscan", "--pristine-tar", "--no-interactive"
|
||||
]
|
||||
# Check dch was called
|
||||
assert subprocess_calls[4][0][0] == "dch"
|
||||
assert subprocess_calls[5][0][0] == "dch"
|
||||
|
||||
def test_existing_checkout_clean(self, tmp_path, monkeypatch):
|
||||
"""Test updating a package that's already checked out and clean."""
|
||||
monkeypatch.setattr(
|
||||
debian_todo,
|
||||
"load_source_info_map",
|
||||
lambda: {"mypkg": {"vcs_git": "homeassistant-team", "uploaders": ""}},
|
||||
lambda: {
|
||||
"mypkg": {
|
||||
"team": "homeassistant-team",
|
||||
"vcs_git": "https://salsa.debian.org/homeassistant-team/deps/mypkg.git",
|
||||
"uploaders": "",
|
||||
}
|
||||
},
|
||||
)
|
||||
monkeypatch.setattr(debian_todo, "DEBIAN_SRC_BASE", tmp_path)
|
||||
|
||||
|
|
@ -806,7 +846,9 @@ class TestUpdatePackage:
|
|||
monkeypatch.setattr(debian_todo.shutil, "which", lambda _: "/usr/bin/tool")
|
||||
|
||||
# Mock the update functions to avoid needing debian/ directory
|
||||
with patch("debian_todo.run_package_updates"):
|
||||
with patch("debian_todo.run_package_updates"), patch(
|
||||
"debian_todo.save_watch_snapshot"
|
||||
):
|
||||
debian_todo.update_package("mypkg")
|
||||
|
||||
# Should not call salsa checkout
|
||||
|
|
@ -815,17 +857,24 @@ class TestUpdatePackage:
|
|||
|
||||
# Should call git status, gbp pq, gbp import-orig, dch
|
||||
assert subprocess_calls[0][0] == ["git", "status", "--porcelain"]
|
||||
assert subprocess_calls[1][0] == ["gbp", "pq", "import"]
|
||||
assert subprocess_calls[2][0] == ["gbp", "pq", "switch"]
|
||||
assert subprocess_calls[3][0][0] == "gbp"
|
||||
assert subprocess_calls[4][0][0] == "dch"
|
||||
assert subprocess_calls[1][0] == ["gbp", "pq", "drop"]
|
||||
assert subprocess_calls[2][0] == ["gbp", "pq", "import"]
|
||||
assert subprocess_calls[3][0] == ["gbp", "pq", "switch"]
|
||||
assert subprocess_calls[4][0][0] == "gbp"
|
||||
assert subprocess_calls[5][0][0] == "dch"
|
||||
|
||||
def test_existing_checkout_dirty(self, tmp_path, monkeypatch):
|
||||
"""Test that update aborts if there are uncommitted changes."""
|
||||
monkeypatch.setattr(
|
||||
debian_todo,
|
||||
"load_source_info_map",
|
||||
lambda: {"mypkg": {"vcs_git": "python-team", "uploaders": ""}},
|
||||
lambda: {
|
||||
"mypkg": {
|
||||
"team": "python-team",
|
||||
"vcs_git": "https://salsa.debian.org/python-team/deps/mypkg.git",
|
||||
"uploaders": "",
|
||||
}
|
||||
},
|
||||
)
|
||||
monkeypatch.setattr(debian_todo, "DEBIAN_SRC_BASE", tmp_path)
|
||||
|
||||
|
|
@ -851,7 +900,13 @@ class TestUpdatePackage:
|
|||
monkeypatch.setattr(
|
||||
debian_todo,
|
||||
"load_source_info_map",
|
||||
lambda: {"mypkg": {"vcs_git": "python-team", "uploaders": ""}},
|
||||
lambda: {
|
||||
"mypkg": {
|
||||
"team": "python-team",
|
||||
"vcs_git": "https://salsa.debian.org/python-team/deps/mypkg.git",
|
||||
"uploaders": "",
|
||||
}
|
||||
},
|
||||
)
|
||||
monkeypatch.setattr(debian_todo, "DEBIAN_SRC_BASE", tmp_path)
|
||||
|
||||
|
|
@ -873,7 +928,13 @@ class TestUpdatePackage:
|
|||
monkeypatch.setattr(
|
||||
debian_todo,
|
||||
"load_source_info_map",
|
||||
lambda: {"mypkg": {"vcs_git": "python-team", "uploaders": ""}},
|
||||
lambda: {
|
||||
"mypkg": {
|
||||
"team": "python-team",
|
||||
"vcs_git": "https://salsa.debian.org/python-team/deps/mypkg.git",
|
||||
"uploaders": "",
|
||||
}
|
||||
},
|
||||
)
|
||||
monkeypatch.setattr(debian_todo, "DEBIAN_SRC_BASE", tmp_path)
|
||||
|
||||
|
|
@ -906,7 +967,13 @@ class TestUpdatePackage:
|
|||
monkeypatch.setattr(
|
||||
debian_todo,
|
||||
"load_source_info_map",
|
||||
lambda: {"mypkg": {"vcs_git": "python-team", "uploaders": ""}},
|
||||
lambda: {
|
||||
"mypkg": {
|
||||
"team": "python-team",
|
||||
"vcs_git": "https://salsa.debian.org/python-team/deps/mypkg.git",
|
||||
"uploaders": "",
|
||||
}
|
||||
},
|
||||
)
|
||||
monkeypatch.setattr(debian_todo, "DEBIAN_SRC_BASE", tmp_path)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue