Open WFT opened 1 year ago
@WFT currently how the unit tests are constructed, either directly or through subclassing you can override the direct method used to make the HTTP call, do any validation required on the inputs, and then return any arbitrary response
https://github.com/apple/app-store-server-library-python/blob/2d11b06188cd24c4e8751bf1b10de59333c6a819/tests/test_api_client.py#L381-L405, or if you are looking for a higher level override, _make_request can be overridden which takes the request and response before they are parsed to/from JSON. This could be extended I believe to create the stubbed behavior you are describing
@alexanderjordanbaker Yeah I think that makes sense. In my codebase I've just been using a general-purpose HTTP mocking library (https://github.com/gabrielfalcao/HTTPretty -- wish it were a little more maintained). I think that to make a really great testing experience though, it'd be nice if we could get it into this library.
Feature request: I'd like the ability to create mock responses to API client calls which will be returned by the next call to a specific client method.
Use case
I would like to do unit testing for my server's use of the library. I want to test the following features of my server:
Example code
Here's an example test one could write: