This repository has been archived on 2023-01-02. You can view files and clone it, but cannot push or open issues or pull requests.
django-pyvows/django_pyvows/http_helpers.py

29 lines
616 B
Python
Raw Normal View History

2012-03-08 18:57:32 +00:00
#!/usr/bin/python
# -*- coding: utf-8 -*-
2011-08-22 17:37:21 +00:00
2015-07-18 20:33:33 +00:00
class RetrocompatibleResponse(object):
def __init__(self, response):
self.response = response
2011-08-22 17:37:21 +00:00
2015-07-18 20:33:33 +00:00
@property
def status(self):
return self.response.status_code
2011-08-22 17:37:21 +00:00
2015-07-18 20:33:33 +00:00
def __iter__(self):
yield self
yield self.response.content
2011-08-22 17:37:21 +00:00
def get(url):
2015-07-18 20:33:33 +00:00
from django.test.client import Client
client = Client()
resp = client.get(url)
return RetrocompatibleResponse(resp), resp.content
2011-08-22 17:37:21 +00:00
2015-07-18 20:33:33 +00:00
def post(url, data):
from django.test.client import Client
client = Client()
return RetrocompatibleResponse(client.post(url, data))