Files
biz-bud/tests/stubs/requests/__init__.py
Travis Vasceannie 8ad47a7640 Modernize research graph metadata for LangGraph v1 (#60)
* Modernize research graph metadata for LangGraph v1

* Update src/biz_bud/core/langgraph/graph_builder.py

Co-authored-by: qodo-merge-pro[bot] <151058649+qodo-merge-pro[bot]@users.noreply.github.com>

---------

Co-authored-by: qodo-merge-pro[bot] <151058649+qodo-merge-pro[bot]@users.noreply.github.com>
2025-09-19 03:01:18 -04:00

62 lines
1.3 KiB
Python

"""Minimal requests stub for unit tests."""
from __future__ import annotations
from dataclasses import dataclass
from typing import Any, Mapping
class RequestException(Exception):
"""Base exception matching the interface of requests.RequestException."""
class HTTPError(RequestException):
pass
@dataclass
class Response:
status_code: int = 200
text: str = ""
_json: Mapping[str, Any] | None = None
def json(self) -> Mapping[str, Any]:
return dict(self._json or {})
def raise_for_status(self) -> None:
if 400 <= self.status_code < 600:
raise HTTPError(f"HTTP {self.status_code}: {self.text}")
def _make_response(status_code: int = 200, **kwargs: Any) -> Response:
payload = kwargs.get("json")
text = kwargs.get("text", "")
return Response(status_code=status_code, text=text, _json=payload)
def get(url: str, **kwargs: Any) -> Response: # noqa: D401 - parity with requests
return _make_response(**kwargs)
def post(url: str, **kwargs: Any) -> Response:
return _make_response(**kwargs)
def put(url: str, **kwargs: Any) -> Response:
return _make_response(**kwargs)
def delete(url: str, **kwargs: Any) -> Response:
return _make_response(**kwargs)
__all__ = [
"Response",
"RequestException",
"HTTPError",
"get",
"post",
"put",
"delete",
]