test(collector): add filtering optimization and edge case tests
- test_filtered_repos_have_no_api_calls: prouve que get_latest_release et get_milestones ne sont pas appelés pour les repos exclus par le filtre include - test_collect_all_include_empty_list: documente le contrat implicite où include=[] est équivalent à include=None (tous les repos inclus) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -206,3 +206,26 @@ class TestCollectAllFiltering:
|
||||
result = collect_all(client, exclude=["alpha", "beta"])
|
||||
|
||||
assert result == []
|
||||
|
||||
def test_filtered_repos_have_no_api_calls(self):
|
||||
"""Repos excluded by include filter must not trigger enrichment API calls."""
|
||||
client = self._setup_client(["gitea-dashboard", "infra-core", "notes"])
|
||||
|
||||
collect_all(client, include=["dashboard"])
|
||||
|
||||
# Only gitea-dashboard passed the filter — enrichment calls must target it only
|
||||
client.get_latest_release.assert_called_once_with("admin", "gitea-dashboard")
|
||||
client.get_milestones.assert_called_once_with("admin", "gitea-dashboard")
|
||||
|
||||
def test_collect_all_include_empty_list(self):
|
||||
"""include=[] behaves like include=None — all repos are returned.
|
||||
|
||||
The contract: an empty list is falsy, so `if include:` is False, meaning
|
||||
no inclusion filter is applied and every repo is included before exclude.
|
||||
"""
|
||||
client = self._setup_client(["alpha", "beta", "gamma"])
|
||||
|
||||
result_none = collect_all(client)
|
||||
result_empty = collect_all(client, include=[])
|
||||
|
||||
assert [r.name for r in result_empty] == [r.name for r in result_none]
|
||||
|
||||
Reference in New Issue
Block a user