fix: Normalize nullable repository descriptions #55
|
|
@ -84,7 +84,7 @@ async def context() -> JSONResponse:
|
||||||
} if isinstance(e, TimeoutError) else None)
|
} if isinstance(e, TimeoutError) else None)
|
||||||
user_model = User(id=user_data["id"], login=user_data["login"], full_name=user_data.get("full_name", ""), email=user_data.get("email", ""))
|
user_model = User(id=user_data["id"], login=user_data["login"], full_name=user_data.get("full_name", ""), email=user_data.get("email", ""))
|
||||||
repo_models = [
|
repo_models = [
|
||||||
Repo(id=r["id"], name=r["name"], full_name=r["full_name"], description=r.get("description", ""), url=r["html_url"], updated_at=r.get("updated_at", ""))
|
Repo(id=r["id"], name=r["name"], full_name=r["full_name"], description=r.get("description") or "", url=r["html_url"], updated_at=r.get("updated_at", ""))
|
||||||
for r in repo_data[:50]
|
for r in repo_data[:50]
|
||||||
if isinstance(r, dict)
|
if isinstance(r, dict)
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -62,4 +62,32 @@ async def test_context_normalizes_nullable_issue_collections(monkeypatch):
|
||||||
issue = json.loads(response.body)["issues"][0]
|
issue = json.loads(response.body)["issues"][0]
|
||||||
|
|
||||||
assert issue["labels"] == []
|
assert issue["labels"] == []
|
||||||
assert issue["assignees"] == []
|
assert issue["assignees"] == []
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.anyio
|
||||||
|
async def test_context_normalizes_nullable_repository_description(monkeypatch):
|
||||||
|
async def user():
|
||||||
|
return {"id": 1, "login": "timmy"}
|
||||||
|
|
||||||
|
async def empty_collection():
|
||||||
|
return []
|
||||||
|
|
||||||
|
async def repo_collection():
|
||||||
|
return [{
|
||||||
|
"id": 54,
|
||||||
|
"name": "dashboard",
|
||||||
|
"full_name": "stackchain/dashboard",
|
||||||
|
"description": None,
|
||||||
|
"html_url": "https://forge.example/stackchain/dashboard",
|
||||||
|
}]
|
||||||
|
|
||||||
|
monkeypatch.setattr(main, "current_user", user)
|
||||||
|
monkeypatch.setattr(main, "repos", repo_collection)
|
||||||
|
monkeypatch.setattr(main, "issues", empty_collection)
|
||||||
|
monkeypatch.setattr(main, "pull_requests", empty_collection)
|
||||||
|
|
||||||
|
response = await main.context()
|
||||||
|
repository = json.loads(response.body)["repos"][0]
|
||||||
|
|
||||||
|
assert repository["description"] == ""
|
||||||
Loading…
Reference in New Issue
Block a user