Surface programming errors in user fetches
This commit is contained in:
+1
-1
@@ -162,7 +162,7 @@ async def _fetch_source_username(
|
|||||||
) -> tuple[str, tuple[dict[str, int], bool] | Exception]:
|
) -> tuple[str, tuple[dict[str, int], bool] | Exception]:
|
||||||
try:
|
try:
|
||||||
return username, await _fetch_with_cache(cache, key, fetcher)
|
return username, await _fetch_with_cache(cache, key, fetcher)
|
||||||
except Exception as exc:
|
except (GitHubSourceError, GiteaSourceError) as exc:
|
||||||
return username, exc
|
return username, exc
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -65,6 +65,25 @@ async def test_fetch_source_usernames_skips_failed_accounts() -> None:
|
|||||||
assert stale is False
|
assert stale is False
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_fetch_source_usernames_does_not_swallow_programming_errors() -> None:
|
||||||
|
def broken_fetcher(username):
|
||||||
|
async def fetch():
|
||||||
|
raise TypeError("bad shape")
|
||||||
|
|
||||||
|
return fetch
|
||||||
|
|
||||||
|
with pytest.raises(TypeError, match="bad shape"):
|
||||||
|
await _fetch_source_usernames(
|
||||||
|
None,
|
||||||
|
"github",
|
||||||
|
["octocat", "hubot"],
|
||||||
|
date(2026, 1, 1),
|
||||||
|
date(2026, 1, 1),
|
||||||
|
broken_fetcher,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_fetch_source_usernames_keeps_cache_after_username_list_changes() -> None:
|
async def test_fetch_source_usernames_keeps_cache_after_username_list_changes() -> None:
|
||||||
with tempfile.TemporaryDirectory(dir=Path.cwd()) as temp_dir:
|
with tempfile.TemporaryDirectory(dir=Path.cwd()) as temp_dir:
|
||||||
|
|||||||
Reference in New Issue
Block a user