тесты и фкисы клиента
Some checks failed
CI / Lint (ruff + mypy) (push) Failing after 36s
CI / Run tests (push) Has been skipped
CI / Docker build test (push) Successful in 21s

This commit is contained in:
2026-03-30 17:02:03 +07:00
parent 8c25c17382
commit 03aa7805d1
2 changed files with 104 additions and 3 deletions

View File

@@ -52,6 +52,36 @@ class GlitchTipClient:
return results
async def _get_paginated_with_fallbacks(
self,
path: str,
param_candidates: list[dict],
*,
fallback_filter=None,
) -> list:
last_error: Exception | None = None
for index, candidate in enumerate(param_candidates):
try:
results = await self._get_paginated(path, params=candidate)
if fallback_filter is not None:
results = [item for item in results if fallback_filter(item)]
return results
except httpx.HTTPStatusError as exc:
last_error = exc
if exc.response.status_code != 422 or index == len(param_candidates) - 1:
raise
logger.warning(
"GlitchTip rejected issue query params for %s with 422; "
"retrying with a simpler request",
path,
)
if last_error is not None:
raise last_error
return []
@staticmethod
def _parse_next_cursor(link_header: str) -> str | None:
for part in link_header.split(","):
@@ -72,9 +102,17 @@ class GlitchTipClient:
async def list_issues(
self, project_slug: str, query: str = "is:unresolved", sort: str = "date"
) -> list[dict]:
return await self._get_paginated(
f"/api/0/projects/{settings.glitchtip_org_slug}/{project_slug}/issues/",
params={"query": query, "sort": sort},
path = f"/api/0/projects/{settings.glitchtip_org_slug}/{project_slug}/issues/"
return await self._get_paginated_with_fallbacks(
path,
[
{"query": query, "sort": sort},
{"query": query},
{},
],
fallback_filter=(
lambda issue: (issue.get("status") or "unresolved").lower() == "unresolved"
),
)
async def get_issue(self, issue_id: int) -> dict: