Page MenuHomeSoftware Heritage

api/tests: add a few test for the whole rpc client/server stack
ClosedPublic

Authored by douardda on Oct 10 2019, 4:31 PM.

Details

Summary

This uses both

  • the client test fixture (from pytest-flask) to allow to easily call RPCServerApp based application methods,
  • a requests Adapter class to make the RPCClient based proxy route the HTTP requests directly to the RPCServerApp test client above, without the need for a running HTTP server.

This adapter implements the send() method to call the flake test app open()
method (instead of doing a real network connection), and convert the
wertzeug based Response object into a requests one.

ing this stack, implements a few tests for an RPC client/server communication
session.

Depends on D2108

Diff Detail

Repository
rDCORE Foundations and core functionalities
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

rebase and rephrase the ci message

ardumont added inline comments.
swh/core/api/tests/test_rpc_client_server.py
57

Don't you want to summarize a tad why you choose to monkeypatch the .session here?
instead of using the RPCClient's.

This revision is now accepted and ready to land.Oct 11 2019, 1:48 PM

add comments/docs and move the impl. of the rpc_client fixture in the plugin

under the name swh_rpc_client. It now uses another (!) fixture
(swh_rpc_client_class, to be declared in the test file) that returns
the class (inherited from RPCClient) to be used for the tests.

[really] add comments/docs and move the impl. of the rpc_client fixture in the plugin

under the name swh_rpc_client. It now uses another (!) fixture
(swh_rpc_client_class, to be declared in the test file) that returns
the class (inherited from RPCClient) to be used for the tests.

Also clear the adapters list of RPCClient's Session instead of replacing
this later in the swh_rpc_client() fixture.