2 ms·
That works fine for files, but what if the integration is with a third party service for example? You can create an actual mock networked service but it's much
by riffraff 1y ago
That works fine for files, but what if the integration is with a third party service for example?
You can create an actual mock networked service but it's much more work.
I think this is an example explaining what seems like a good practice for using mocks in python to me, the actual code in the post is barely "supporting cast".
- efortis 1y agoIf it's HTTP you can create the fixtures and serve them with a mock server. I'm a frontend dev, so backend APIs are like 3rd parties to me. I use a browser extension for scraping actual backend responses, which downloads them with a filename convention the mock server understands. I mostly use it for development, but also for setting up screenshot tests. For example, PATCH /select 'api/user(locked-out).GET.423.json' screenshot the app and pixel diff it PATCH /select 'api/user.GET.200.json' screenshot…
- leosanchez 1y ago> I use a browser extension for scraping actual backend responses Can you tell the name of the extension ?
- efortis 1y agohttps://github.com/ericfortis/download-http-requests-browser-ext https://github.com/ericfortis/download-http-requests-browser...
- deleted 1y ago[deleted]
- Izkata 1y agoYou can automate it with the right libraries, such as https://github.com/kevin1024/vcrpy https://github.com/kevin1024/vcrpy This one runs the real request and saves the response, faking it later by returning what it saved instead of making the request again.