fix: centralize discovery transport handling

This commit is contained in:
NotoriousRebel
2026-08-26 18:38:56 -04:00
parent fabaea3886
commit 0e4324f2cb
17 changed files with 316 additions and 90 deletions
@@ -2,6 +2,7 @@ from __future__ import annotations
import asyncio
import contextlib
import json
from typing import TYPE_CHECKING, Any
import pytest
@@ -18,6 +19,8 @@ class FakeResponse:
def __init__(self, payload: dict[str, Any], links: dict[str, Any]) -> None:
self.payload = payload
self.links = links
self.headers: dict[str, str] = {}
self.content = self
async def __aenter__(self) -> FakeResponse:
return self
@@ -31,6 +34,9 @@ class FakeResponse:
async def json(self) -> dict[str, Any]:
return self.payload
async def iter_any(self):
yield json.dumps(self.payload).encode()
@pytest.fixture
def install_github_responses(monkeypatch: pytest.MonkeyPatch):
@@ -53,6 +59,10 @@ def install_github_responses(monkeypatch: pytest.MonkeyPatch):
requested_urls.append(url)
return next(response_iterator)
def request(self, method: str, url: str, **_kwargs: Any) -> FakeResponse:
assert method == 'GET'
return self.get(url)
@contextlib.asynccontextmanager
async def fake_open_session(**_kwargs: object) -> AsyncIterator[FakeSession]:
async with FakeSession(headers={}) as session: