File: utils.py

package info (click to toggle)
python-huum 0.8.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 272 kB
  • sloc: python: 454; makefile: 2
file content (24 lines) | stat: -rw-r--r-- 648 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from typing import Any

from aiohttp import ClientResponseError


class MockResponse:
    def __init__(self, json_data: dict[str, Any], status_code: int, text: str = "") -> None:
        self._json = json_data
        self._text = text

        self.status = status_code

    async def json(self) -> dict[str, Any]:
        return self._json

    def raise_for_status(self) -> None:
        if self.status >= 400:
            raise ClientResponseError(
                None,  # type: ignore
                None,  # type: ignore
                status=self.status,
                message="Bad Request",
                headers=None,
            )