예제 #1
0
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
예제 #2
0
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
예제 #3
0
    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()))
예제 #4
0
    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()))
예제 #5
0
    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()))