-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update the docs to reference new features and the more recent way that statements are written. Change-Id: I7fc00143b9ab4366a00324aaf59d59baecf9da4a
- Loading branch information
Jamie Lennox
committed
Jan 19, 2015
1 parent
9547a7b
commit aeb66e9
Showing
8 changed files
with
235 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
=============== | ||
Request History | ||
=============== | ||
|
||
The object returned from creating a mock or registering a URI in an adapter is capable of tracking and querying the history of requests that this mock responded to. | ||
|
||
Called | ||
====== | ||
|
||
The easiest way to test if a request hit the adapter is to simply check the called property. | ||
|
||
.. doctest:: | ||
|
||
>>> import requests | ||
>>> import requests_mock | ||
|
||
>>> with requests_mock.mock() as m: | ||
... m.get('http://test.com, text='resp') | ||
... resp = requests.get('http://test.com') | ||
... | ||
>>> m.called | ||
True | ||
>>> m.call_count | ||
1 | ||
|
||
Request Objects | ||
=============== | ||
|
||
The history of objects that passed through the `mocker`/`adapter` can also be retrieved | ||
|
||
.. doctest:: | ||
|
||
>>> history = m.request_history | ||
>>> len(history) | ||
1 | ||
>>> history[0].method | ||
'GET' | ||
>>> history[0].url | ||
'http://test.com/' | ||
|
||
This request history object is a wrapper around a standard :py:class:`requests.Request` object with some additional information that make the interface more workable (as the :py:class:`~requests.Request` object is generally not dealt with by users. | ||
|
||
These additions include: | ||
|
||
:text: The data of the request converted into a unicode string. | ||
:json: The data of the request loaded from json into python objects. | ||
:qs: The query string of the request. See :py:meth:`urllib.parse.parse_qs` for information on the return format. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.