Changeset View
Changeset View
Standalone View
Standalone View
swh/core/pytest_plugin.py
Show First 20 Lines • Show All 249 Lines • ▼ Show 20 Lines | |||||
@pytest.fixture | @pytest.fixture | ||||
def swh_rpc_adapter(app): | def swh_rpc_adapter(app): | ||||
"""Fixture that generates a requests.Adapter instance that | """Fixture that generates a requests.Adapter instance that | ||||
can be used to test client/servers code based on swh.core.api classes. | can be used to test client/servers code based on swh.core.api classes. | ||||
See swh/core/api/tests/test_rpc_client_server.py for an example of usage. | See swh/core/api/tests/test_rpc_client_server.py for an example of usage. | ||||
""" | """ | ||||
with app.test_client() as client: | client = app.test_client() | ||||
yield RPCTestAdapter(client) | yield RPCTestAdapter(client) | ||||
class RPCTestAdapter(BaseAdapter): | class RPCTestAdapter(BaseAdapter): | ||||
def __init__(self, client): | def __init__(self, client): | ||||
self._client = client | self._client = client | ||||
def build_response(self, req, resp): | def build_response(self, req, resp): | ||||
response = requests.Response() | response = requests.Response() | ||||
▲ Show 20 Lines • Show All 102 Lines • Show Last 20 Lines |