|
10 | 10 | import pathlib |
11 | 11 | import re |
12 | 12 | import typing |
13 | | -from collections import defaultdict |
14 | 13 |
|
15 | 14 | import pytest |
16 | 15 | import requests_mock |
@@ -117,10 +116,8 @@ def test_cooldown_filters_recent_version( |
117 | 116 | candidate = result.mapping["test-pkg"] |
118 | 117 | # 2.0.0 is 2 days old (within cooldown); 1.3.2 is 11 days old (outside). |
119 | 118 | assert str(candidate.version) == "1.3.2" |
120 | | - # 2.0.0 should be logged as skipped; 1.3.2 should not. |
121 | | - assert "skipping 2.0.0" in caplog.text |
122 | | - assert "cooldown" in caplog.text |
123 | | - assert "skipping 1.3.2" not in caplog.text |
| 119 | + # 2.0.0 should be logged as blocked; 1.3.2 should not appear in the summary. |
| 120 | + assert "cooldown blocked 1 version(s): 2.0.0" in caplog.text |
124 | 121 |
|
125 | 122 |
|
126 | 123 | def test_cooldown_disabled_selects_latest() -> None: |
@@ -171,17 +168,11 @@ def test_cooldown_rejects_candidate_without_upload_time( |
171 | 168 | upload_time=None, |
172 | 169 | ) |
173 | 170 | provider = resolver.PyPIProvider(cooldown=_COOLDOWN) |
174 | | - req = Requirement("test-pkg") |
175 | | - requirements: typing.Any = defaultdict(list) |
176 | | - requirements["test-pkg"].append(req) |
177 | | - incompatibilities: typing.Any = defaultdict(list) |
178 | 171 |
|
179 | 172 | with caplog.at_level(logging.DEBUG, logger="fromager.resolver"): |
180 | | - result = provider.validate_candidate( |
181 | | - "test-pkg", requirements, incompatibilities, candidate |
182 | | - ) |
| 173 | + result = provider.is_blocked_by_cooldown(candidate) |
183 | 174 |
|
184 | | - assert result is False |
| 175 | + assert result is True |
185 | 176 | assert "upload_time unknown" in caplog.text |
186 | 177 | assert "1.0.0" in caplog.text |
187 | 178 |
|
@@ -567,8 +558,7 @@ def test_gitlab_cooldown_filters_recent_tag( |
567 | 558 | candidate = result.mapping["test-pkg"] |
568 | 559 | # v0.0.3 (2025-05-14) is inside the 7-day window; v0.0.2 is the next newest. |
569 | 560 | assert str(candidate.version) == "0.0.2" |
570 | | - assert "skipping 0.0.3" in caplog.text |
571 | | - assert "cooldown" in caplog.text |
| 561 | + assert "cooldown blocked 1 version(s): 0.0.3" in caplog.text |
572 | 562 |
|
573 | 563 |
|
574 | 564 | def test_gitlab_cooldown_disabled_selects_latest() -> None: |
@@ -639,17 +629,11 @@ def test_github_cooldown_skips_with_warning( |
639 | 629 | url="https://github.com/example/pkg/archive/v1.0.0.tar.gz", |
640 | 630 | upload_time=None, |
641 | 631 | ) |
642 | | - req = Requirement("test-pkg") |
643 | | - requirements: typing.Any = defaultdict(list) |
644 | | - requirements["test-pkg"].append(req) |
645 | | - incompatibilities: typing.Any = defaultdict(list) |
646 | 632 |
|
647 | 633 | with caplog.at_level(logging.WARNING, logger="fromager.resolver"): |
648 | | - result = provider.validate_candidate( |
649 | | - "test-pkg", requirements, incompatibilities, candidate |
650 | | - ) |
| 634 | + result = provider.is_blocked_by_cooldown(candidate) |
651 | 635 |
|
652 | | - assert result is True |
| 636 | + assert result is False |
653 | 637 | assert "cooldown cannot be enforced" in caplog.text |
654 | 638 |
|
655 | 639 |
|
|
0 commit comments