diff --git a/swh/core/api/__init__.py b/swh/core/api/__init__.py --- a/swh/core/api/__init__.py +++ b/swh/core/api/__init__.py @@ -152,7 +152,8 @@ # Send the request. return self.post(meth._endpoint_path, post_data) - attributes[meth_name] = meth_ + if meth_name not in attributes: + attributes[meth_name] = meth_ class RPCClient(metaclass=MetaRPCClient): diff --git a/swh/core/api/tests/test_rpc_client.py b/swh/core/api/tests/test_rpc_client.py --- a/swh/core/api/tests/test_rpc_client.py +++ b/swh/core/api/tests/test_rpc_client.py @@ -26,11 +26,18 @@ def serializer_test(self, data, db=None, cur=None): ... + @remote_api_endpoint('overridden/endpoint') + def overridden_method(self, data): + return 'foo' + class Testclient(RPCClient): backend_class = TestStorage extra_type_encoders = extra_encoders extra_type_decoders = extra_decoders + def overridden_method(self, data): + return 'bar' + def callback(request, context): assert request.headers['Content-Type'] == 'application/x-msgpack' context.headers['Content-Type'] = 'application/x-msgpack' @@ -71,3 +78,8 @@ def test_client_extra_serializers(rpc_client): res = rpc_client.serializer_test(['foo', ExtraType('bar', b'baz')]) assert res == ExtraType({'spam': 'egg'}, 'qux') + + +def test_client_overridden_method(rpc_client): + res = rpc_client.overridden_method('foo') + assert res == 'bar'