Created
October 2, 2013 19:18
-
-
Save spulec/6799081 to your computer and use it in GitHub Desktop.
HTTPretty runner
This file contains hidden or 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
Fixtures/Command line runner | |
It would be awesome if there were a command line runner. For example, imagine I run a django app that relies on a ton of external APIs. It would be great for development if I could run `httpretty manage.py runserver` and all of the calls would be mocked accordingly. `httpretty` would import a file named `.httpretty.py` which would setup all the routing configuration. | |
Happy to do some work on this if it sounds interesting. | |
Example `.httpretty.py` | |
```python | |
import httpretty | |
httpretty.register_uri( | |
httpretty.GET, | |
"http://search.example.com:9200/_mget", | |
body=request_callback | |
) | |
def request_callback(method, uri, headers): | |
search = uri.querystring.get('q') | |
return { | |
"deals": [ | |
{ | |
"title": "Awesome %s deal" % search | |
} | |
] | |
} | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment