Changeset View
Changeset View
Standalone View
Standalone View
swh/core/api/tests/test_rpc_client_server.py
Show First 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | class RPCTestClient(RPCClient): | ||||
backend_class = RPCTest2 | backend_class = RPCTest2 | ||||
@pytest.fixture | @pytest.fixture | ||||
def app(): | def app(): | ||||
# This fixture is used by the 'swh_rpc_adapter' fixture | # This fixture is used by the 'swh_rpc_adapter' fixture | ||||
# which is defined in swh/core/pytest_plugin.py | # which is defined in swh/core/pytest_plugin.py | ||||
application = RPCServerApp('testapp', backend_class=RPCTest) | application = RPCServerApp('testapp', backend_class=RPCTest) | ||||
@application.errorhandler(Exception) | @application.errorhandler(Exception) | ||||
def my_error_handler(exception): | def my_error_handler(exception): | ||||
return error_handler(exception, encode_data_server) | return error_handler(exception, encode_data_server) | ||||
return application | return application | ||||
@pytest.fixture | @pytest.fixture | ||||
def swh_rpc_client_class(): | def swh_rpc_client_class(): | ||||
# This fixture is used by the 'swh_rpc_client' fixture | # This fixture is used by the 'swh_rpc_client' fixture | ||||
# which is defined in swh/core/pytest_plugin.py | # which is defined in swh/core/pytest_plugin.py | ||||
return RPCTestClient | return RPCTestClient | ||||
Show All 26 Lines | |||||
def test_api_typeerror(swh_rpc_client): | def test_api_typeerror(swh_rpc_client): | ||||
with pytest.raises(RemoteException) as exc_info: | with pytest.raises(RemoteException) as exc_info: | ||||
swh_rpc_client.raise_typeerror() | swh_rpc_client.raise_typeerror() | ||||
assert exc_info.value.args[0]['type'] == 'TypeError' | assert exc_info.value.args[0]['type'] == 'TypeError' | ||||
assert exc_info.value.args[0]['args'] == ['Did I pass through?'] | assert exc_info.value.args[0]['args'] == ['Did I pass through?'] | ||||
assert str(exc_info.value) \ | assert ( | ||||
str(exc_info.value) | |||||
== "<RemoteException 500 TypeError: ['Did I pass through?']>" | == "<RemoteException 500 TypeError: ['Did I pass through?']>" | ||||
) |