fix: let check_freshness read the profile report

check_freshness ran profile_sync with --json and the detection flags,
which profile_sync refuses, so --profiles always reported an unreadable
report. The version check now lives on the report and travels in the
JSON and markdown outputs; check_freshness asks for --json
--check-version only.
This commit is contained in:
Abdessamad Derraz committed 2026-10-21 06:09:15 +02:00
1 parent 1a41e6a964
commit d6fc66274f
4 files changed
+74 -25

No files matched your search

+18
View File
@@ -388,6 +388,24 @@ class ProfileSummaryTests(unittest.TestCase):
self.assertNotIn("a", by_subject)
self.assertNotIn("b", by_subject)
def test_profile_sync_accepts_the_command_it_is_given(self):
"""--json with the detection flags was refused, so --profiles read an
empty stdout and reported "unreadable report" on every run."""
import profile_sync # noqa: PLC0415
captured = []
def run(cmd, **kwargs):
captured.append(cmd)
return mock.Mock(returncode=0, stdout="[]", stderr="")
with mock.patch.object(cf.subprocess, "run", side_effect=run):
cf.check_profiles(True, offline=True)
(cmd,) = captured
args = profile_sync.build_parser().parse_args(cmd[2:])
profile_sync._refuse_flag_combinations(args)
self.assertTrue(args.as_json)
def test_a_non_list_report_is_an_error_not_a_crash(self):
findings = cf.summarize_profile_sync({"oops": 1})
self.assertEqual(findings[0].status, cf.ERROR)
+14 -1
View File
@@ -4022,7 +4022,20 @@ class TestOutputModesApplyTheirFlags(unittest.TestCase):
self.assertIn("prose under an older pin", out)
def test_extras_are_refused_with_json(self):
code, _, err = self._main("--json", "--check-version")
code, _, err = self._main("--json", "--detect-new-files")
self.assertEqual(code, 1)
self.assertIn("--detect-new-files", err)
def test_json_carries_the_version_check(self):
"""check_freshness asks for --json --check-version: refused, its
profile row read an empty report as unreadable on every run."""
code, out, err = self._main("--json", "--check-version")
self.assertEqual(code, 0, err)
rows = json.loads(out)
self.assertTrue(all("version" in row and "page_version" in row for row in rows))
def test_rankings_refuse_the_version_check(self):
code, _, err = self._main("--triage", "--check-version")
self.assertEqual(code, 1)
self.assertIn("--check-version", err)