fix: always report broken internal links + show source pages
Previously, broken links that were part of the baseline ("known broken")
disappeared from the terminal output (score=0, no Klartext mention).
- differ.py: build reverse link index to record which pages link to
each broken URL; "pages" field added to new_broken/known_broken entries
- plain.py: klartext_befunde() now includes known_broken_urls alongside
new_broken_urls — broken links are always reported until fixed
- __main__.py: report shows "gefunden auf: <page>" for every broken entry,
known entries labelled "[bekannt, noch nicht behoben]"
- 3 new tests (169 total)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
30ac95a5cf
commit
b01344dcd8
5 changed files with 57 additions and 6 deletions
|
|
@ -234,6 +234,20 @@ class TestBrokenLinks:
|
|||
assert len(result["new_broken_urls"]) == 1
|
||||
assert result["new_broken_urls"][0]["url"] == "https://b.info/missing/"
|
||||
assert result["new_broken_urls"][0]["status"] == 404
|
||||
assert "pages" in result["new_broken_urls"][0]
|
||||
|
||||
def test_broken_url_includes_source_pages(self):
|
||||
"""broken entry lists the pages that link to the broken URL."""
|
||||
home = self._make_page("https://b.info/")
|
||||
home["links"]["a"] = [{"url": "https://b.info/missing/", "class": "internal"}]
|
||||
baseline = {"https://b.info/": self._make_page("https://b.info/")}
|
||||
current = {
|
||||
"https://b.info/": home,
|
||||
"https://b.info/missing/": self._make_page("https://b.info/missing/", status=404),
|
||||
}
|
||||
result = compare_snapshots(baseline, current, BASE_CFG)
|
||||
entry = result["new_broken_urls"][0]
|
||||
assert "https://b.info/" in entry["pages"]
|
||||
|
||||
def test_known_broken_not_in_new(self):
|
||||
broken_page = {"https://b.info/old/": self._make_page("https://b.info/old/", status=404)}
|
||||
|
|
@ -242,6 +256,7 @@ class TestBrokenLinks:
|
|||
result = compare_snapshots(baseline, current, BASE_CFG)
|
||||
assert result["new_broken_urls"] == []
|
||||
assert len(result["known_broken_urls"]) == 1
|
||||
assert "pages" in result["known_broken_urls"][0]
|
||||
|
||||
def test_broken_url_scores(self):
|
||||
result = score_diff({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue