Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #9 from jezdez/master

Fixing the MockHttpRequest helper
  • Loading branch information...
commit 7ab8e2c1a83904f82eff6389cb74fc0001370282 2 parents 181330b + c12f891
@dcramer authored
Showing with 4 additions and 8 deletions.
  1. +4 −8 mock_django/http.py
View
12 mock_django/http.py
@@ -6,7 +6,6 @@
:license: Apache License 2.0, see LICENSE for more details.
"""
-from mock import Mock
from django.contrib.auth.models import AnonymousUser
from django.http import HttpRequest
from django.utils.datastructures import MergeDict
@@ -20,7 +19,6 @@ def __init__(self, *args, **kwargs):
super(WsgiHttpRequest, self).__init__(*args, **kwargs)
self.user = AnonymousUser()
self.session = {}
- self.url = '/'
self.META = {}
self.GET = {}
self.POST = {}
@@ -31,9 +29,6 @@ def _get_request(self):
return self._request
REQUEST = property(_get_request)
- def build_absolute_uri(self, location=None):
- return self.url
-
def _get_raw_post_data(self):
if not hasattr(self, '_raw_post_data'):
self._raw_post_data = urlencode(self.POST)
@@ -42,10 +37,10 @@ def _get_raw_post_data(self):
def _set_raw_post_data(self, data):
self._raw_post_data = data
self.POST = {}
- raw_post_data = property(_set_raw_post_data)
+ raw_post_data = property(_get_raw_post_data, _set_raw_post_data)
-def MockHttpRequest(url='/', method='GET', GET=None, POST=None, META=None):
+def MockHttpRequest(path='/', method='GET', GET=None, POST=None, META=None):
if GET is None:
GET = {}
if POST is None:
@@ -55,12 +50,13 @@ def MockHttpRequest(url='/', method='GET', GET=None, POST=None, META=None):
if META is None:
META = {
'REMOTE_ADDR': '127.0.0.1',
+ 'SERVER_PORT': '8000',
'HTTP_REFERER': '',
'SERVER_NAME': 'testserver',
}
request = WsgiHttpRequest()
- request.url = url
+ request.path = request.path_info = path
request.method = method
request.META = META
request.GET = GET
Please sign in to comment.
Something went wrong with that request. Please try again.