mirror of https://github.com/zulip/zulip.git
docs: Update doc on how to mock HTTP responses.
We prefer to use respones module rather than a custom system to mock the HTTP responses. Rewritten by tabbott to provide more context/explanation.
This commit is contained in:
parent
3cc6ff57db
commit
803e199063
|
@ -301,9 +301,15 @@ from Django as well as our own custom helpers. Here is an example:
|
|||
Follow [this link](../subsystems/settings.html#testing-non-default-settings) for more
|
||||
information on the "settings" context manager.
|
||||
|
||||
A common use is to prevent a call to a third-party service from using
|
||||
the Internet; `git grep mock.patch | grep requests` is a good way to
|
||||
find several examples of doing this.
|
||||
Zulip has several features, like outgoing webhooks or social
|
||||
authentication, that made outgoing HTTP requests to external
|
||||
servers. We test those features using the excellent
|
||||
[responses](https://pypi.org/project/responses/) library, which has a
|
||||
nice interface for mocking `requests` calls to return whatever HTTP
|
||||
response from the exteranl server we need for the test. you can find
|
||||
examples with `git grep responses.add`. Zulip's own `HostRequestMock`
|
||||
class should be used only for low-level tests for code that expects to
|
||||
receive Django HttpRequest object.
|
||||
|
||||
## Zulip testing philosophy
|
||||
|
||||
|
|
Loading…
Reference in New Issue