-
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.
This is a pretty significant change. This version of HoverPy now uses…
… Hoverfly 0.10.1. There's been some reshuffling of the modules, instead of having the main HoverPy class inside __init__.py, it is now in hp.py. A decorators.py file has also been added. A lib folder has been added, which contains configurators, to get other networking libraries to play with hoverpy more easily. Support and examples have been added for tornado and twisted. The docs were altered quite a lot to show all these changes.
- Loading branch information
Showing
51 changed files
with
1,146 additions
and
1,637 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
*.db | ||
.venv | ||
.eggs | ||
*.bak | ||
|
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,108 @@ | ||
HoverPy | ||
======= | ||
|
||
HoverPy speeds up and simplifies Python development and testing that involves downstream HTTP / HTTPS services. It does so by using a high-performance Go caching proxy to capture, simulate, modify and synthesize network traffic. | ||
|
||
.. code:: python | ||
from hoverpy import capture, simulate | ||
import requests | ||
@capture("requests.db") | ||
def captured_get(): | ||
print(requests.get("http://time.jsontest.com").json()) | ||
@simulate("requests.db") | ||
def simulated_get(): | ||
print(requests.get("http://time.jsontest.com").json()) | ||
captured_get() | ||
simulated_get() | ||
This grants several benefits: | ||
|
||
- Increased development speed | ||
- Increased test speed | ||
- Ability to work offline | ||
- A deterministic test environment | ||
- Ability to modify traffic | ||
- Ability to sythesize traffic | ||
- Ability to simulate network latency | ||
|
||
.. code:: python | ||
from hoverpy import capture, modify | ||
import requests | ||
@simulate("requests.db", delays=[("time.json.com", 1000)]) | ||
def simulated_latency(): | ||
print(requests.get("http://time.jsontest.com").json()) | ||
@modify(middleware="python middleware.py") | ||
def modified_request(): | ||
print(requests.get("http://time.jsontest.com").json()) | ||
simulated_latency() | ||
modified_request() | ||
If/when the downstream service you are testing against changes, then you can simply delete your db file, and capture the test results again. Or you could have versioned db files for services that use versioning. | ||
|
||
HoverPy uses `Hoverfly <http://hoverfly.io>`__ a Service Virtualisation server written in GoLang. For this reason it is rock solid in terms of speed and reliability. | ||
|
||
Library Support | ||
~~~~~~~~~~~~~~~ | ||
|
||
HoverPy works great with the following HTTP clients out of the box: | ||
|
||
- tornado | ||
- twisted | ||
- requests | ||
- urllib2 | ||
- urllib3 | ||
- pysimplesoap | ||
- etc. | ||
|
||
Since HoverPy can act as a proxy or a reverse proxy, it can easily be made to work with any networking library or framework. | ||
|
||
Source | ||
~~~~~~ | ||
|
||
https://github.com/SpectoLabs/hoverpy/ | ||
|
||
.. image:: hoverpy_logo.png | ||
|
||
License | ||
~~~~~~~ | ||
|
||
HoverPy uses Apache License V2. See LICENSE.txt for more details. | ||
|
||
.. |PyPI version| image:: https://badge.fury.io/py/hoverpy.svg | ||
:target: https://pypi.python.org/pypi/hoverpy | ||
.. |RTD badget| image:: https://readthedocs.org/projects/hoverpy/badge/?version=latest | ||
:target: http://hoverpy.readthedocs.io/en/latest/ | ||
.. |Build Status| image:: https://travis-ci.org/SpectoLabs/hoverpy.svg?branch=master | ||
:target: https://travis-ci.org/SpectoLabs/hoverpy | ||
|
||
Contents | ||
======== | ||
|
||
.. toctree:: | ||
:maxdepth: 3 | ||
|
||
pages/installation | ||
pages/introduction | ||
pages/usage/usage | ||
|
||
Indices and tables | ||
================== | ||
|
||
* :ref:`genindex` | ||
* :ref:`modindex` | ||
* :ref:`search` | ||
|
||
|
||
| | ||
|PyPI version| |RTD badget| |Build Status| | ||
|
||
| |
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 |
---|---|---|
@@ -1,54 +1,15 @@ | ||
.. basic | ||
.. _basic: | ||
|
||
===== | ||
basic | ||
===== | ||
|
||
This is by far the simplest example on how to get started with HoverPy. Please run this example using: | ||
This is by far the simplest example on how to get started with HoverPy. | ||
|
||
``$ python examples/basic/basic.py`` | ||
|
||
You should see your IP address show up twice. Let's walk through the code to see what's happening. | ||
|
||
:: | ||
|
||
>>> from hoverpy import HoverPy | ||
>>> import requests | ||
|
||
|
||
Above, we start by importing our most important class `HoverPy`. We also bring in ``requests`` for our http traffic. | ||
|
||
.. hoverpy: hoverpy.html#module-hoverpy | ||
Now let's create our HoverPy object in capture mode. We do so with a `with` statement as this is the pythonic way, although this is not a necessity. | ||
|
||
:: | ||
|
||
>>> with HoverPy(capture=True) as hoverpy: | ||
|
||
|
||
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. | ||
|
||
:: | ||
|
||
>>> 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. | ||
|
||
:: | ||
|
||
>>> hoverpy.simulate() | ||
|
||
|
||
Print the json from our get request. This time the data comes from the store. | ||
|
||
:: | ||
|
||
>>> print(requests.get("http://ip.jsontest.com/myip").json()) | ||
.. literalinclude:: ../../../examples/basic/basic.py | ||
|
||
``$ python examples/basic/basic.py`` | ||
|
||
Requests.db | ||
----------- | ||
You should see time printed twice. Notice the time is the same on each request, that is because the ``simulated_get`` was served from data that was captured while calling ``captured_get``. | ||
|
||
You may have noticed this created a ``requests.db`` inside your current directory. This is a boltdb database, holding our requests, and their responses. |
Oops, something went wrong.