Add multi-username activity support
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
from datetime import date
|
||||
|
||||
import pytest
|
||||
|
||||
from app.main import QueryOptions, collect_merged_activity
|
||||
from app.settings import Settings
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_collect_merged_activity_combines_multiple_usernames(monkeypatch) -> None:
|
||||
settings = Settings(
|
||||
_env_file=None,
|
||||
GITHUB_USERNAME="octocat, hubot",
|
||||
GITEA_BASE_URL="https://gitea.example.com",
|
||||
GITEA_USERNAME="alice, bob",
|
||||
)
|
||||
|
||||
github_calls: list[str] = []
|
||||
gitea_calls: list[str] = []
|
||||
|
||||
async def fake_fetch_github_activity(username, token, from_date, to_date, timeout_seconds=20.0):
|
||||
github_calls.append(username)
|
||||
return {"2026-01-01": 1 if username == "octocat" else 2}
|
||||
|
||||
async def fake_fetch_gitea_activity(base_url, username, token, from_date, to_date, timeout_seconds=20.0):
|
||||
gitea_calls.append(username)
|
||||
return {"2026-01-01": 3 if username == "alice" else 4}
|
||||
|
||||
monkeypatch.setattr("app.main.fetch_github_activity", fake_fetch_github_activity)
|
||||
monkeypatch.setattr("app.main.fetch_gitea_activity", fake_fetch_gitea_activity)
|
||||
|
||||
result = await collect_merged_activity(
|
||||
settings=settings,
|
||||
cache=None,
|
||||
options=QueryOptions(year=None, days=1, theme="light", source="all"),
|
||||
)
|
||||
|
||||
assert sorted(github_calls) == ["hubot", "octocat"]
|
||||
assert sorted(gitea_calls) == ["alice", "bob"]
|
||||
assert result.merged["2026-01-01"] == {"github": 3, "gitea": 7, "total": 10}
|
||||
Reference in New Issue
Block a user