1

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.

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.

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.

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

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

TL;DR: how do you test @rpc functions using unit test?

  • Possible duplicate of [Testing Spyne application](https://stackoverflow.com/questions/19383937/testing-spyne-application) – mx0 Sep 20 '18 at 17:15

1 Answers1

1

I believe if you are using a service inside a test, that test should not be a unit test.

you might want to consider use factory_boy or mock, 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.

bluebird_lboro
  • 601
  • 5
  • 17