-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
417 additions
and
249 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,45 @@ | ||
.. basic | ||
Basic Example | ||
******** | ||
|
||
|
||
Import hoverpy's main class: HoverPy | ||
|
||
.. code:: python | ||
from hoverpy import HoverPy | ||
Import requests and random for http | ||
|
||
.. code:: python | ||
import requests | ||
Create our HoverPy object in capture mode | ||
|
||
.. code:: python | ||
hp = HoverPy(capture=True) | ||
Print the json from our get request. Hoverpy acted as a proxy: it made | ||
the request on our behalf, captured it, and returned it to us. | ||
|
||
.. code:: python | ||
print(requests.get("http://ip.jsontest.com/myip").json()) | ||
Switch HoverPy to simulate mode. HoverPy no longer acts as a proxy; all | ||
it does from now on is replay the captured data. | ||
|
||
.. code:: python | ||
hp.simulate() | ||
Print the json from our get request. This time the data comes from the | ||
store. | ||
|
||
.. code:: python | ||
print(requests.get("http://ip.jsontest.com/myip").json()) | ||
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,85 @@ | ||
.. delays | ||
delays Example | ||
******** | ||
|
||
|
||
Import hoverpy's main class: HoverPy | ||
|
||
.. code:: python | ||
from hoverpy import HoverPy | ||
Import requests and random for http and testing | ||
|
||
.. code:: python | ||
import requests | ||
import random | ||
Create our HoverPy object in capture mode | ||
|
||
.. code:: python | ||
hp = HoverPy(capture=True) | ||
This function either generates a echo server url, or a md5 url it is | ||
seeded so that we get the exact same requests on capture as we do on | ||
simulate | ||
|
||
.. code:: python | ||
def getServiceData(): | ||
for i in range(10): | ||
random.seed(i) | ||
print( | ||
requests.get( | ||
random.choice( | ||
[ | ||
"http://echo.jsontest.com/i/%i" % | ||
i, | ||
"http://md5.jsontest.com/?text=%i" % | ||
i])).json()) | ||
Make the requests to the desired host dependencies | ||
|
||
.. code:: python | ||
print("capturing responses from echo server\n") | ||
getServiceData() | ||
There are two ways to add delays. One is to call the delays method with | ||
the desired delay rules passed in as a json document | ||
|
||
.. code:: python | ||
print(hp.delays({"data": [ | ||
{ | ||
"urlPattern": "md5.jsontest.com", | ||
"delay": 1000 | ||
} | ||
] | ||
} | ||
)) | ||
The other more pythonic way is to call addDelay(...) | ||
|
||
.. code:: python | ||
print(hp.addDelay(urlPattern="echo.jsontest.com", delay=3000)) | ||
Now let's switch over to simulate mode | ||
|
||
.. code:: python | ||
print(hp.simulate()) | ||
Make the requests. This time HoverFly adds the simulated delays. these | ||
requests would normally be run asynchronously, and we could deal | ||
gracefully with the dependency taking too long to respond | ||
|
||
.. code:: python | ||
print("\nreplaying delayed responses from echo server\n") | ||
getServiceData() | ||
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,30 @@ | ||
hoverpy package | ||
=============== | ||
|
||
Submodules | ||
---------- | ||
|
||
hoverpy.config module | ||
--------------------- | ||
|
||
.. automodule:: hoverpy.config | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
hoverpy.generateDocs module | ||
--------------------------- | ||
|
||
.. automodule:: hoverpy.generateDocs | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
|
||
Module contents | ||
--------------- | ||
|
||
.. automodule:: hoverpy | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
Oops, something went wrong.