новый мииф\
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import logging
|
||||
from urllib.parse import parse_qs, urlparse
|
||||
|
||||
import httpx
|
||||
|
||||
@@ -88,9 +89,15 @@ class GlitchTipClient:
|
||||
if 'rel="next"' not in part or 'results="true"' not in part or "cursor=" not in part:
|
||||
continue
|
||||
|
||||
start = part.index("cursor=") + len("cursor=")
|
||||
end = part.find(">", start)
|
||||
return part[start:end] if end != -1 else part[start:]
|
||||
url_start = part.find("<")
|
||||
url_end = part.find(">", url_start + 1)
|
||||
if url_start == -1 or url_end == -1:
|
||||
continue
|
||||
|
||||
parsed = urlparse(part[url_start + 1 : url_end].strip())
|
||||
cursor_values = parse_qs(parsed.query).get("cursor")
|
||||
if cursor_values:
|
||||
return cursor_values[0]
|
||||
|
||||
return None
|
||||
|
||||
|
||||
@@ -44,6 +44,18 @@ async def test_list_issues_retries_without_query_params_on_422() -> None:
|
||||
]
|
||||
|
||||
|
||||
def test_parse_next_cursor_extracts_only_cursor_value() -> None:
|
||||
link_header = (
|
||||
'<https://glitchtip.example.com/api/0/projects/org/backend-production/issues/'
|
||||
'?limit=100&cursor=cD0yMDI2LTAzLTI2KzIxJTNBNTklM0EyMS4xNjkxNDklMkIwMCUzQTAw'
|
||||
'%26limit%3D100>; rel="next"; results="true"; cursor="..."'
|
||||
)
|
||||
|
||||
cursor = GlitchTipClient._parse_next_cursor(link_header)
|
||||
|
||||
assert cursor == "cD0yMDI2LTAzLTI2KzIxJTNBNTklM0EyMS4xNjkxNDklMkIwMCUzQTAw&limit=100"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_list_issues_preserves_non_422_errors() -> None:
|
||||
def handler(request: httpx.Request) -> httpx.Response:
|
||||
|
||||
Reference in New Issue
Block a user