3.0.ipv8.test.REST.rest_base

Classes

Functions

Module Contents

class 3.0.ipv8.test.REST.rest_base.BodyCapture

Bases: io.BytesIO, aiohttp.abc.AbstractStreamWriter

Helper-class to capture RESTResponse bodies.

async write(value: bytes) None

Write to our Bytes stream.

class 3.0.ipv8.test.REST.rest_base.MockRequest(path: str = '', method: str = 'GET', query: dict | None = None, match_info: dict[str, str] | None = None, payload_writer: aiohttp.abc.AbstractStreamWriter | None = None)

Bases: aiohttp.web_request.Request

Base class for mocked REST requests.

class Transport

A fake transport that does nothing.

closing = False
get_extra_info(_: str) None

Get extra info, which is always None.

is_closing() bool

Get the closing state.

_transport
_query
_match_info
property match_info: aiohttp.web_urldispatcher.UrlMappingMatchInfo

Get the match info (the infohash in the url).

property query: multidict.MultiDictProxy[str]

Overwrite the query with the query passed in our constructor.

async json(*, loads: aiohttp.typedefs.JSONDecoder = DEFAULT_JSON_DECODER) dict

Get the json equivalent of the query (i.e., just the query).

property transport: asyncio.Transport | None

Overwrite the transport with our fake transport.

async 3.0.ipv8.test.REST.rest_base.response_to_bytes(response: aiohttp.web.Response) bytes

Get the bytes of a RESTResponse’s body.

async 3.0.ipv8.test.REST.rest_base.response_to_json(response: aiohttp.web.Response) Any

Get the JSON dict of a RESTResponse’s body.