twisted / treq

Python requests like API built on top of Twisted's HTTP client.
Other
587 stars 139 forks source link

treq.auth omnibus #315

Closed twm closed 3 years ago

twm commented 3 years ago
twm commented 3 years ago

Happy to see mock.Mock gone :)

More of this to come!

For my tests, I stopped using spies that record and for which you assert the behaviour later, and instead I am using and ReplayAgentBacked similar to the angularjs $httpBackend

You pass a list of expected URLs and request data, but you also able to return a response. In this way, you can test chained agent interactions, without touching the network.

For example, I am using for SAML login testing in which more than 1 requests are made...and the response of the first request is used in the second request.

treq.testing, specifically RequestTraversalAgent, is exactly this! I'm a big fan of this style. It's actually the part of treq I use most, though it has some pretty rough edges. I didn't use it in this case for two reasons:

adiroiban commented 3 years ago

I think that the spy is OK for unit tests and treq.testing can be used "network-free" integration tests.

twm commented 3 years ago

Thank you very much for the review and feedback, @adiroiban!