How to test RPC of SOAP web services?
<p>I am currently learning building a SOAP web services with django and spyne. I have successfully tested my model using unit test. However, when I tried to test all those @rpc functions, I have no luck there at all.</p>

<p>What I have tried in testing those @rpc functions:
1. Get dummy data in model database
2. Start a server at localhost:8000
3. Create a suds.Client object that can communicate with localhost:8000
4. Try to invoke @rpc functions from the suds.Client object, and test if the output matches what I expected.</p>

<p>However, when I run the test, I believe the test got blocked by the running server at localhost:8000 thus no test code can be run while the server is running.</p>

<p>I tried to make the server run on a different thread, but that messed up my test even more.</p>

<p>I have searched as much as I could online and found no materials that can answer this question.</p>

<p>TL;DR: how do you test @rpc functions using unit test?</p>

<p>I believe if you are using a service inside a test, that test should not be a <strong>unit</strong> test.</p>

<p>you might want to consider use <strong>factory_boy</strong> or <strong>mock</strong>, both of them are python modules to mock or fake a object, for instance, to fake a object to give a response to your rpc call.</p>

python django testing rpc spyne