Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

Create a Django request object that mocks a real one.

Project Description
Django Request Mock
===================

Django Request Mock is an helper that allows you to generate synthetic request objects that mimic a real one, generated after a real request is being received by the framework.

Useful when coding in an HTTP isolated environment, which prevents you from accessing the request object, such as a cron method or a Celery task. This allows you to render templates and build absolute URIs from such contexts, for instance.

The request object is generated using your settings, and by default contains all the values of a request being sent to your website's default domain, using the SITE_URL configuration variable (can be of that form: https://example.com/)

## Configuration

* Ensure `SITE_URL` is defined in your **settings.py**, with a value such as 'https://example.com/'

* When you need to generate a request mock object, simply use the following code:

```python
from request_mock import request_mock

# Generate the mock object
# request_mock(base, path, user) where each argument is optional
request = request_mock()

# Can also be
request = request_mock(
base='https://other.org/',
path='/some/path/for/mock/request/',
user=User.objects.get(username='dummy.user')
)
```

* All done!
Release History

Release History

This version
History Node

0.1.4

History Node

0.1.3

History Node

0.1.2

History Node

0.1.1

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django-request-mock-0.1.4.tar.gz (2.6 kB) Copy SHA256 Checksum SHA256 Source Mar 8, 2014

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting