In my latest Python project, utilizing Twisted, I've tried to be good at using the unittest module. At a high level, I'm building two RESTful APIs designed specifically to talk to each other. For most requests, I can just use DummyRequest and test the rendered values against an expected constant and that's been working fine.
However, I've got a few cases where the design requires a request on one server that (among other things) then sends a request to the other server, but doesn't really care about the response. What matters is that the request happens.
Like I said, I can test that functionality on the other side perfectly fine, but I'm getting stumped on how to test to ensure that the data was sent over. My ideas so far are either
I'm leaning towards the second option as it seems more pythonic, but also a bit hacky.
Thoughts?
Twisted comes with its own unit-testing framework, called Trial. As you might imagine, it's well-suited for testing your networking code. Here's a tutorial to start you off.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With