Skip to content

Instantly share code, notes, and snippets.

@spulec
Created October 2, 2013 19:18
Show Gist options
  • Save spulec/6799081 to your computer and use it in GitHub Desktop.
Save spulec/6799081 to your computer and use it in GitHub Desktop.
HTTPretty runner
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