pook
pook copied to clipboard
HTTP traffic mocking and testing made easy in Python
A possible interface implementation: ```python def matcher(request, mock): return request.url.path == '/v1/foo' pook.get('api.server.com').match_func(matcher).match_func(matcher) ``` Overload method for specific matcher function usage: ```python def json_matcher(body): return body == '{"foo": true}' pook.get('api.server.com').body(json_matcher)...
Persistent mock definition are reused across volatile mock instances via inheritance. Exposes mock request/response chainable interfaces: ```python pook.defaults.request.headers({'Client': 'pook/0.1.6'}) pook.defaults.response.headers({'Server': 'pook/0.1.6'}) ```
Limit outgoing bytes in mocked HTTP responses. This is a nice-to-have feature.
Some "unlucky" people still relies on it. This is purely a nice-to-have feature. PR are very welcome.
`Mock::body` ignores the `binary` parameter passed to it and always passes `binary=False` to the matcher constructor. https://github.com/h2non/pook/blob/ff30ca754b7569245640e593ffc7389c91a3e500/src/pook/mock.py#L414
Pook has a feature that allows passing specially formatted strings, which pook interprets as a regex pattern to be parsed during matching. In all cases where this feature is supported,...
Query params are always strings and should be compared as such, even if passed as something else to the mock constructor. For example, the following should work: ```py pook.get("https://example.com").params({"x": 1})...
Implements the deprecation warning described in #128. The PR is still a draft as it needs release notes.
## How to prepare your code for this change > **Note** > > The version with the deprecation notice has not yet been released, this copy is here just to...