fix: say why a version page or check went unread

This commit is contained in:
Abdessamad Derraz committed 2026-11-21 19:50:33 +01:00
1 parent dae6b3a146
commit 91e385598e
7 files changed
+91 -13

No files matched your search

+11
View File
@@ -906,6 +906,17 @@ class AReleasePageMakesAProfileStale(unittest.TestCase):
self.assertEqual(found["altirra"], STALE)
self.assertEqual(found["mednafen"], OK)
def test_an_unread_release_page_is_unknown_not_skipped(self):
"""An unreadable page read like a profile with no version_source:
SKIPPED by nature, and a moved or dead feed went unseen."""
rows = [{"name": "altirra", "skipped": "unsupported host: virtualdub.org",
"declared_version": "4.40", "page_version": None,
"page_version_unread": "page absent"}]
(overall, row) = summarize_profile_sync(rows)
self.assertEqual(row.status, UNKNOWN)
self.assertEqual(row.detail, "version page unread: page absent")
def test_a_release_with_no_genuine_copy_waits_for_the_next(self):
"""FPse 13.0 exists only as rebuilt copies: the profile stays on 12.1
and flagging it on every run said nothing new. 13.1 would."""
+39 -1
View File
@@ -5999,7 +5999,45 @@ class AnOffForgeProfileWatchesItsReleasePage(unittest.TestCase):
}}
with mock.patch.object(upstream, "fetch_page",
return_value="<p>Altirra 4.50 released</p>"):
self.assertEqual(versions.page_version(profile, "cache", False), "4.50")
self.assertEqual(versions.page_version(profile, "cache", False), ("4.50", None))
def test_an_unread_page_says_why(self):
"""A fetch error, an uncached page, a 404 and a pattern miss all
came back None, the error only printed: the JSON could not tell a
moved release page from a profile without one."""
from unittest import mock
profile = {"emulator": "Altirra", "version_source": {
"url": "https://example.test/altirra", "pattern": r"Altirra (\d+\.\d+) released",
}}
answers = [
(upstream.NotCachedError("cold"), "not cached offline"),
(None, "page absent"),
("<p>nothing here</p>", "pattern not found"),
(upstream.UpstreamError("HTTP 500"), "https://example.test/altirra: HTTP 500"),
]
for answer, reason in answers:
effect = {"side_effect": answer} if isinstance(answer, Exception) else {"return_value": answer}
with self.subTest(reason=reason), \
mock.patch.object(upstream, "fetch_page", **effect), \
mock.patch("sys.stderr") as stderr:
self.assertEqual(versions.page_version(profile, "cache", True), (None, reason))
stderr.write.assert_not_called()
def test_an_uncached_page_offline_is_not_an_absent_one(self):
with tempfile.TemporaryDirectory() as cache, self.assertRaises(upstream.NotCachedError):
upstream.fetch_page("https://example.invalid/never-cached", cache, True)
def test_the_reason_reaches_the_json_and_the_text(self):
report = ProfileReport(name="altirra", entries=[], counts={}, skipped="unsupported host: x",
declared_version="4.40", page_version_unread="page absent",
version_unread="tag ancestry unread: refused")
payload = report_to_dict(report)
self.assertEqual(payload["page_version_unread"], "page absent")
self.assertEqual(payload["version_unread"], "tag ancestry unread: refused")
text = format_report(report)
self.assertIn("announced unreadable (page absent)", text)
self.assertIn("tag ancestry unread: refused", text)
class ARecaleKeepsTheRepositoryWord(unittest.TestCase):