Skip to content

Commit 869b4a2

Browse files
SirRFIrafal
authored and
rafal
committed
[HttpClient] Add more description about testing
1 parent 908f3d5 commit 869b4a2

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

http_client.rst

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,8 +1391,18 @@ Testing HTTP Clients and Responses
13911391
----------------------------------
13921392

13931393
This component includes the ``MockHttpClient`` and ``MockResponse`` classes to
1394-
use them in tests that need an HTTP client which doesn't make actual HTTP
1395-
requests.
1394+
use them in tests that shouldn't make actual HTTP requests. Such tests can be
1395+
useful, as they are faster and consistent due to not being dependant on
1396+
external service the request would be sent to. In result there is no need to
1397+
worry about the service being online or the request changing some state,
1398+
for example deleting a resource.
1399+
1400+
``MockHttpClient`` implements the ``HttpClientInterface``, just like any actual
1401+
HTTP client in this component. You can use the interface to accept real client
1402+
in your code, while replacing it with ``MockHttpClient`` in the test.
1403+
1404+
When the ``request`` method is used on ``MockHttpClient``, it will respond with
1405+
supplied ``MockResponse``. There are few ways to use it:
13961406

13971407
The first way of using ``MockHttpClient`` is to pass a list of responses to its
13981408
constructor. These will be yielded in order when requests are made::

0 commit comments

Comments
 (0)