Public Member Functions | |
| None | __init__ (self, Server mockserver, Session session, str base_prefix='', *, bool strict_default=False) |
| 'MockserverFixture' | new (self, str prefix) |
| Create mockserver installer with given base prefix. | |
| str | base_url (self) |
| Mockserver base url. | |
| str|None | host (self) |
| Mockserver hostname. | |
| int|None | port (self) |
| Mockserver port. | |
| str | trace_id_header (self) |
| str | span_id_header (self) |
| str | trace_id (self) |
| classes.GenericRequestDecorator | handler (self, str path, *, bool prefix=False, bool raw_request=False, bool json_response=False, bool regex=False, typing.Optional[bool] strict=None) |
| Register basic http handler for path. | |
| classes.JsonRequestDecorator | json_handler (self, str path, *, bool prefix=False, bool raw_request=False, bool regex=False, typing.Optional[bool] strict=None) |
| Register json http handler for path. | |
| classes.GenericRequestDecorator | aiohttp_handler (self, str path, *, bool prefix=False, bool regex=False, typing.Optional[bool] strict=None) |
| classes.JsonRequestDecorator | aiohttp_json_handler (self, str path, *, bool prefix=False, bool regex=False, typing.Optional[bool] strict=None) |
| str | url (self, str path) |
| Builds mockserver url for path. | |
| yarl.URL | url_encoded (self, str path) |
| Builds mockserver url for path. | |
| str | ws_url (self, str path) |
| typing.ContextManager[None] | ignore_trace_id (self) |
| tracing (self, bool value=True) | |
| callinfo.AsyncCallQueue | get_callqueue_for (self, path) |
Public Attributes | |
| base_url | |
Static Public Attributes | |
| make_response = staticmethod(http.make_response) | |
| TimeoutError = http.TimeoutError | |
| NetworkError = http.NetworkError | |
Protected Member Functions | |
| typing.Callable | _handler_installer (self, str path, *, typing.Optional[bool] strict, bool prefix=False, bool raw_request=False, bool json_response=False, bool regex=False) |
| str | _build_fullpath (self, path, bool regex=False) |
Protected Attributes | |
| _server = mockserver | |
| _session = session | |
| _base_prefix = base_prefix | |
| _base_prefix_re = re.escape(base_prefix) | |
| _strict_default = strict_default | |
|
protected |
|
protected |
| classes.GenericRequestDecorator testsuite.mockserver.server.MockserverFixture.aiohttp_handler | ( | self, | |
| str | path, | ||
| * | , | ||
| bool | prefix = False, | ||
| bool | regex = False, | ||
| typing.Optional[bool] | strict = None ) |
| classes.JsonRequestDecorator testsuite.mockserver.server.MockserverFixture.aiohttp_json_handler | ( | self, | |
| str | path, | ||
| * | , | ||
| bool | prefix = False, | ||
| bool | regex = False, | ||
| typing.Optional[bool] | strict = None ) |
| str testsuite.mockserver.server.MockserverFixture.base_url | ( | self | ) |
| callinfo.AsyncCallQueue testsuite.mockserver.server.MockserverFixture.get_callqueue_for | ( | self, | |
| path ) |
| classes.GenericRequestDecorator testsuite.mockserver.server.MockserverFixture.handler | ( | self, | |
| str | path, | ||
| * | , | ||
| bool | prefix = False, | ||
| bool | raw_request = False, | ||
| bool | json_response = False, | ||
| bool | regex = False, | ||
| typing.Optional[bool] | strict = None ) |
Register basic http handler for path.
Returns decorator that registers handler path. Original function is wrapped with :ref:AsyncCallQueue.
:param path: match url by prefix if True exact match otherwise :param raw_request: pass aiohttp.web.Response to handler instead of testsuite.utils.http.Request :param regex: set True to match path as regex pattern :param prefix: set True to match path prefix instead of whole path :param json_response: set True to let handler return json object instead of full response object
.. code-block:: python
@mockserver.handler('/service/path') def handler(request: testsuite.utils.http.Request): return mockserver.make_response('Hello, world!')
| str | None testsuite.mockserver.server.MockserverFixture.host | ( | self | ) |
| typing.ContextManager[None] testsuite.mockserver.server.MockserverFixture.ignore_trace_id | ( | self | ) |
| classes.JsonRequestDecorator testsuite.mockserver.server.MockserverFixture.json_handler | ( | self, | |
| str | path, | ||
| * | , | ||
| bool | prefix = False, | ||
| bool | raw_request = False, | ||
| bool | regex = False, | ||
| typing.Optional[bool] | strict = None ) |
Register json http handler for path.
Returns decorator that registers handler path. Original function is wrapped with :ref:AsyncCallQueue.
:param path: match url by prefix if True exact match otherwise :param raw_request: pass aiohttp.web.Response to handler instead of testsuite.utils.http.Request :param prefix: set True to match path prefix instead of whole path :param regex: set True to match path as regex pattern
.. code-block:: python
@mockserver.json_handler('/service/path') def handler(request: testsuite.utils.http.Request):
return {...}
return mockserver.make_response(...)
| 'MockserverFixture' testsuite.mockserver.server.MockserverFixture.new | ( | self, | |
| str | prefix ) |
| int | None testsuite.mockserver.server.MockserverFixture.port | ( | self | ) |
| str testsuite.mockserver.server.MockserverFixture.span_id_header | ( | self | ) |
| str testsuite.mockserver.server.MockserverFixture.trace_id | ( | self | ) |
| str testsuite.mockserver.server.MockserverFixture.trace_id_header | ( | self | ) |
| testsuite.mockserver.server.MockserverFixture.tracing | ( | self, | |
| bool | value = True ) |
| str testsuite.mockserver.server.MockserverFixture.url | ( | self, | |
| str | path ) |
| yarl.URL testsuite.mockserver.server.MockserverFixture.url_encoded | ( | self, | |
| str | path ) |
| str testsuite.mockserver.server.MockserverFixture.ws_url | ( | self, | |
| str | path ) |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
static |
|
static |
|
static |