3.0.ipv8.test.REST.rest_base ============================ .. py:module:: 3.0.ipv8.test.REST.rest_base Classes ------- .. autoapisummary:: 3.0.ipv8.test.REST.rest_base.BodyCapture 3.0.ipv8.test.REST.rest_base.MockRequest Functions --------- .. autoapisummary:: 3.0.ipv8.test.REST.rest_base.response_to_bytes 3.0.ipv8.test.REST.rest_base.response_to_json Module Contents --------------- .. py:class:: BodyCapture Bases: :py:obj:`io.BytesIO`, :py:obj:`aiohttp.abc.AbstractStreamWriter` Helper-class to capture RESTResponse bodies. .. py:method:: write(value: bytes) -> None :async: Write to our Bytes stream. .. py:class:: 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: :py:obj:`aiohttp.web_request.Request` Base class for mocked REST requests. .. py:class:: Transport A fake transport that does nothing. .. py:attribute:: closing :value: False .. py:method:: get_extra_info(_: str) -> None Get extra info, which is always None. .. py:method:: is_closing() -> bool Get the closing state. .. py:attribute:: _transport .. py:attribute:: _query .. py:attribute:: _match_info .. py:property:: match_info :type: aiohttp.web_urldispatcher.UrlMappingMatchInfo Get the match info (the infohash in the url). .. py:property:: query :type: multidict.MultiDictProxy[str] Overwrite the query with the query passed in our constructor. .. py:method:: json(*, loads: aiohttp.typedefs.JSONDecoder = DEFAULT_JSON_DECODER) -> dict :async: Get the json equivalent of the query (i.e., just the query). .. py:property:: transport :type: asyncio.Transport | None Overwrite the transport with our fake transport. .. py:function:: response_to_bytes(response: aiohttp.web.Response) -> bytes :async: Get the bytes of a RESTResponse's body. .. py:function:: response_to_json(response: aiohttp.web.Response) -> Any :async: Get the JSON dict of a RESTResponse's body.