From 7fffc23120fa5096d001070057a5c32424457a25 Mon Sep 17 00:00:00 2001 From: Michel Alexandre Salim Date: Feb 04 2022 15:14:42 +0000 Subject: s|next_build_req_layer|iterate Signed-off-by: Michel Alexandre Salim --- diff --git a/ebranch/cli.py b/ebranch/cli.py index 8a2d4c6..d55f784 100644 --- a/ebranch/cli.py +++ b/ebranch/cli.py @@ -116,10 +116,10 @@ def unfold_report(report_file: str): default="rawhide-source", show_default=True, ) -def next_build_req_layer(report_file: str, branch: str, ref_repo: str): +def iterate_report(report_file: str, branch: str, ref_repo: str): click.echo( json.dumps( - dnf.get_next_build_req_layer_serialized( + dnf.iterate_report_serialized( report_file, branch, ref_repo=ref_repo ), indent=2, diff --git a/ebranch/dnf.py b/ebranch/dnf.py index c7d4e83..6ee9e23 100644 --- a/ebranch/dnf.py +++ b/ebranch/dnf.py @@ -117,7 +117,7 @@ def unfold_report_serialized(report_file: str): return expanded_report -def get_next_build_req_layer( +def iterate_report( report: dict[str, dict], branch: str, repos: list[str] = [], @@ -137,14 +137,14 @@ def get_next_build_req_layer( return expanded_report -def get_next_build_req_layer_serialized( +def iterate_report_serialized( report_file: str, branch: str, repos: list[str] = [], ref_repo: str = "rawhide-source", ) -> dict[str, dict]: existing_report = load_report(report_file) - expanded_report = get_next_build_req_layer(existing_report, branch, repos, ref_repo) + expanded_report = iterate_report(existing_report, branch, repos, ref_repo) save_report(expanded_report, report_file) return expanded_report diff --git a/tests/test_dnf.py b/tests/test_dnf.py index 183ef4d..c32a693 100644 --- a/tests/test_dnf.py +++ b/tests/test_dnf.py @@ -107,7 +107,7 @@ def test_filter_build_reqs(monkeypatch): } -def test_get_next_build_req_layer(monkeypatch): +def test_report_iterate(monkeypatch): report = { "python-b4": { "build": { @@ -129,7 +129,7 @@ def test_get_next_build_req_layer(monkeypatch): "python-patatt": {"build": {"python-pynacl": ["python3dist(pynacl)"]}} } mock_get_missing.return_value = patatt_brs - result = dnf.get_next_build_req_layer(report, "epel9") + result = dnf.iterate_report(report, "epel9") assert result["python-b4"] == report["python-b4"] assert result["python-dkimpy"] == report["python-dkimpy"] assert result["python-patatt"] == patatt_brs["python-patatt"] @@ -138,21 +138,21 @@ def test_get_next_build_req_layer(monkeypatch): ) -def test_get_next_build_req_layer_serialized(monkeypatch): +def test_remote_iterate_serialized(monkeypatch): mock_load = mock.Mock() - mock_next_layer = mock.Mock() + mock_iterate = mock.Mock() mock_save = mock.Mock() monkeypatch.setattr(dnf, "load_report", mock_load) - monkeypatch.setattr(dnf, "get_next_build_req_layer", mock_next_layer) + monkeypatch.setattr(dnf, "iterate_report", mock_iterate) monkeypatch.setattr(dnf, "save_report", mock_save) orig_report = {"foo": {"build": {"bar": []}}} expanded_report = {"foo": {"build": {"bar": []}}, "bar": {}} mock_load.return_value = orig_report - mock_next_layer.return_value = expanded_report + mock_iterate.return_value = expanded_report report_file = "report.json" - result = dnf.get_next_build_req_layer_serialized(report_file, "epel9") + result = dnf.iterate_report_serialized(report_file, "epel9") mock_load.assert_called_once_with(report_file) - mock_next_layer.assert_called_once_with(orig_report, "epel9", [], "rawhide-source") + mock_iterate.assert_called_once_with(orig_report, "epel9", [], "rawhide-source") mock_save.assert_called_once_with(expanded_report, report_file) assert result == expanded_report