Skip to content

Commit

Permalink
Update generated .rst
Browse files Browse the repository at this point in the history
  • Loading branch information
EvaSDK committed Feb 23, 2015
1 parent 43d8d28 commit 8346d02
Showing 1 changed file with 38 additions and 15 deletions.
53 changes: 38 additions & 15 deletions README.rst
@@ -1,16 +1,15 @@
HTTPretty 0.8.0
HTTPretty 0.8.3
===============

|https://s3-us-west-2.amazonaws.com/s.cdpn.io/18885/httpretty-logo\_1.svg|
|tip for next commit| |Build Status| |instanc.es Badge|
`ChangeLog <NEWS.md>`__
|https://s3-us-west-2.amazonaws.com/s.cdpn.io/18885/httpretty-logo_1.svg|
|tip for next commit| |Build Status| `ChangeLog <NEWS.md>`__

Installing
==========

Since you are interested in HTTPretty you should also be insterested in
Since you are interested in HTTPretty you should also be interested in
speeding up your build. Replace ``pip`` with
```curdling`` <http://clarete.github.io/curdling/>`__ and see your build
`curdling <http://clarete.github.io/curdling/>`__ and see your build
running a lot faster.

You can use curdling to install not only HTTPretty but every dependency
Expand Down Expand Up @@ -313,8 +312,8 @@ Set a callback to allow for dynamic responses based on the request.
@httpretty.activate
def test_response_callbacks():
def request_callback(method, uri, headers):
return (200, headers, "The {} response from {}".format(method, uri))
def request_callback(request, uri, headers):
return (200, headers, "The {} response from {}".format(request.method, uri))
httpretty.register_uri(
httpretty.GET, "https://api.yahoo.com/test",
Expand All @@ -324,6 +323,33 @@ Set a callback to allow for dynamic responses based on the request.
expect(response.text).to.equal('The GET response from https://api.yahoo.com/test')
Dynamic responses can also be used when you have to work with badly
designed APIs where, for example, the same uri and method are used to
handle different requests based on request body which contains xml.

.. code:: python
import requests
import httpretty
@httpretty.activate
def test_response_callbacks():
def request_callback(request, uri, headers):
# parse_xml() extracts important data from request
data = parse_xml(request.body)
# response based on that data
if data.something_important:
return (200, headers, "relevant data")
else:
return (400, headers, "panic mode!")
httpretty.register_uri(
httpretty.GET, "https://api.brilliant-api.com/",
body=request_callback)
response = requests.get('https://api.brilliant-api.com/')
matching regular expressions
----------------------------

Expand Down Expand Up @@ -383,7 +409,6 @@ checking if is enabled

.. code:: python
httpretty.enable()
httpretty.is_enabled().should.be.true
Expand Down Expand Up @@ -448,7 +473,7 @@ Hacking on HTTPretty
====================

create a virtual env
^^^^^^^^^^^^^^^^^^^^
--------------------

you will need
`virtualenvwrapper <http://www.doughellmann.com/projects/virtualenvwrapper/>`__
Expand All @@ -458,14 +483,14 @@ you will need
mkvirtualenv --distribute --no-site-packages HTTPretty
install the dependencies
^^^^^^^^^^^^^^^^^^^^^^^^
------------------------

.. code:: console
pip install -r requirements.txt
next steps:
^^^^^^^^^^^
-----------

1. run the tests with make:

Expand Down Expand Up @@ -516,10 +541,8 @@ There folks made remarkable contributions to HTTPretty:
- Matt Luongo ~> @mhluongo
- James Rowe ~> @JNRowe

.. |https://s3-us-west-2.amazonaws.com/s.cdpn.io/18885/httpretty-logo\_1.svg| image:: https://s3-us-west-2.amazonaws.com/s.cdpn.io/18885/httpretty-logo_1.svg
.. |https://s3-us-west-2.amazonaws.com/s.cdpn.io/18885/httpretty-logo_1.svg| image:: https://s3-us-west-2.amazonaws.com/s.cdpn.io/18885/httpretty-logo_1.svg
.. |tip for next commit| image:: http://tip4commit.com/projects/133.svg
:target: http://tip4commit.com/projects/133
.. |Build Status| image:: https://travis-ci.org/gabrielfalcao/HTTPretty.png?branch=master
:target: https://travis-ci.org/gabrielfalcao/HTTPretty
.. |instanc.es Badge| image:: https://instanc.es/bin/gabrielfalcao/HTTPretty.png
:target: http://instanc.es

0 comments on commit 8346d02

Please sign in to comment.