Limit German archive pagination to filtered results

Exclude the independent latest-release list from archived links and date boundaries. Cover stopping before the requested year, continuing within range, and rejecting pages without a filtered result block.
This commit is contained in:
eezd committed 2026-10-26 22:07:42 +08:00
1 parent c1c52aa0b2
commit 2dedaf3127
3 files changed
+55 -1

No files matched your search

@@ -0,0 +1,28 @@
<!-- 来源:Destatis CPI 归档第 6 页;保留筛选列表和独立最新新闻列表的真实节点。 -->
<html><body>
<div class="l-content-wrapper s-press-search-results">
<div class="c-result"><h3 class="c-result__heading">
<a href="EN/Press/2024/09/PE24_340_611.html">
<span class="c-result__date">
Press release No. 340 of 10 September 2024</span>
Inflation rate at +1.9% in August 2024</a>
</h3></div>
<div class="c-result"><h3 class="c-result__heading">
<a href="EN/Press/2024/08/PE24_329_611.html">
<span class="c-result__date">
Press release No. 329 of 29 August 2024</span>
Inflation rate of +1.9% expected in August 2024</a>
</h3></div>
<a href="SiteGlobals/Forms/Suche/Presse/EN/Pressesuche_Formular_2.html?gtp=350792_list%253D7&amp;cl2Taxonomies_Themen_0=preise&amp;cl2Taxonomies_Themen_1=verbraucherpreisindex" title="page 7" class="forward button">
<img src="/SiteGlobals/Frontend/Images/icons/next.svg?__blob=normal&amp;v=9" title="next page" alt="next page">
</a>
</div>
<div class="l-content-wrapper s-press-search-results">
<div class="c-result"><h3 class="c-result__heading">
<a href="EN/Press/2026/10/PE26_364_611.html">
<span class="c-result__date">
Press release No. 364 of 13 October 2026</span>
Inflation rate at +3.3% in September 2026</a>
</h3></div>
</div>
</body></html>
+22
View File
@@ -0,0 +1,22 @@
from datetime import date
from pathlib import Path
import pytest
from alphapulse.calendar.europe_archives import destatis_links
@pytest.mark.parametrize("start,expected,has_next", [
(date(2025, 1, 1), [], False),
(date(2024, 1, 1), ["EN/Press/2024/09/PE24_340_611.html", "EN/Press/2024/08/PE24_329_611.html"], True),
])
def test_destatis_archive_only_uses_filtered_results_for_links_and_date_boundary(start, expected, has_next):
body = (Path(__file__).parent / "fixtures/europe/de_archive_before_start.html").read_text()
links, following = destatis_links(body, start, date(2026, 10, 26))
assert links == ["https://www.destatis.de/" + path for path in expected]
assert (following is not None) is has_next
def test_destatis_archive_rejects_a_page_without_the_filtered_result_block():
with pytest.raises(ValueError, match="筛选结果"):
destatis_links("<html><body>Access denied</body></html>", date(2025, 1, 1), date(2026, 10, 26))