Permalink
Browse files

Renamed the `url` parameter of the MockHttpRequest to `path` since th…

…at's what I expected it to be.

Also added a SERVER_PORT value to the default META so the `build_absolute_uri` method actually works.
  • Loading branch information...
1 parent bb13fa3 commit c12f891b1603aa5bb9b63730330c9ef79c13a620 @jezdez jezdez committed Dec 20, 2012
Showing with 3 additions and 7 deletions.
  1. +3 −7 mock_django/http.py
View
@@ -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)
@@ -45,7 +40,7 @@ def _set_raw_post_data(self, 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

0 comments on commit c12f891

Please sign in to comment.