def MockHttpRequest(path='/', method='GET', GET=None, POST=None, META=None, user=None): if GET is None: GET = {} if POST is None: POST = {} else: method = 'POST' if META is None: META = { 'REMOTE_ADDR': '127.0.0.1', 'SERVER_PORT': '8000', 'HTTP_REFERER': '', 'SERVER_NAME': 'testserver', } if user is not None: user = user request = WsgiHttpRequest() request.path = request.path_info = path request.method = method request.META = META request.GET = GET request.POST = POST request.user = user return request
def test__get_request(self): wsgi_r = WsgiHttpRequest() expected_items = MergeDict({}, {}).items() wsgi_r.GET = {} wsgi_r.POST = {} self.assertListEqual(sorted(expected_items), sorted(wsgi_r._get_request().items()))
def test__get_request(self): from django.utils.datastructures import MergeDict wsgi_r = WsgiHttpRequest() expected_items = MergeDict({}, {}).items() wsgi_r.GET = {} wsgi_r.POST = {} self.assertListEqual(sorted(expected_items), sorted(wsgi_r._get_request().items()))