Пример #1
0
 def test_wsgirequest_repr(self):
     request = WSGIRequest({"PATH_INFO": "/somepath/", "REQUEST_METHOD": "get", "wsgi.input": BytesIO(b"")})
     request.GET = {"get-key": "get-value"}
     request.POST = {"post-key": "post-value"}
     request.COOKIES = {"post-key": "post-value"}
     request.META = {"post-key": "post-value"}
     self.assertEqual(
         repr(request),
         str_prefix(
             "<WSGIRequest\npath:/somepath/,\nGET:{%(_)s'get-key': %(_)s'get-value'},\nPOST:{%(_)s'post-key': %(_)s'post-value'},\nCOOKIES:{%(_)s'post-key': %(_)s'post-value'},\nMETA:{%(_)s'post-key': %(_)s'post-value'}>"
         ),
     )
     self.assertEqual(build_request_repr(request), repr(request))
     self.assertEqual(
         build_request_repr(
             request,
             path_override="/otherpath/",
             GET_override={"a": "b"},
             POST_override={"c": "d"},
             COOKIES_override={"e": "f"},
             META_override={"g": "h"},
         ),
         str_prefix(
             "<WSGIRequest\npath:/otherpath/,\nGET:{%(_)s'a': %(_)s'b'},\nPOST:{%(_)s'c': %(_)s'd'},\nCOOKIES:{%(_)s'e': %(_)s'f'},\nMETA:{%(_)s'g': %(_)s'h'}>"
         ),
     )
Пример #2
0
 def test_wsgirequest_repr(self):
     request = WSGIRequest({'REQUEST_METHOD': 'get', 'wsgi.input': BytesIO(b'')})
     self.assertEqual(repr(request), "<WSGIRequest: GET '/'>")
     request = WSGIRequest({'PATH_INFO': '/somepath/', 'REQUEST_METHOD': 'get', 'wsgi.input': BytesIO(b'')})
     request.GET = {'get-key': 'get-value'}
     request.POST = {'post-key': 'post-value'}
     request.COOKIES = {'post-key': 'post-value'}
     request.META = {'post-key': 'post-value'}
     self.assertEqual(repr(request), "<WSGIRequest: GET '/somepath/'>")
Пример #3
0
 def test_wsgirequest_repr(self):
     request = WSGIRequest({"REQUEST_METHOD": "get", "wsgi.input": BytesIO(b"")})
     self.assertEqual(repr(request), str_prefix("<WSGIRequest: GET '/'>"))
     request = WSGIRequest({"PATH_INFO": "/somepath/", "REQUEST_METHOD": "get", "wsgi.input": BytesIO(b"")})
     request.GET = {"get-key": "get-value"}
     request.POST = {"post-key": "post-value"}
     request.COOKIES = {"post-key": "post-value"}
     request.META = {"post-key": "post-value"}
     self.assertEqual(repr(request), str_prefix("<WSGIRequest: GET '/somepath/'>"))
Пример #4
0
Файл: tests.py Проект: 10sr/hue
 def test_wsgirequest_repr(self):
     request = WSGIRequest({'PATH_INFO': '/somepath/', 'REQUEST_METHOD': 'get', 'wsgi.input': BytesIO(b'')})
     request.GET = {'get-key': 'get-value'}
     request.POST = {'post-key': 'post-value'}
     request.COOKIES = {'post-key': 'post-value'}
     request.META = {'post-key': 'post-value'}
     self.assertEqual(repr(request), str_prefix("<WSGIRequest\npath:/somepath/,\nGET:{%(_)s'get-key': %(_)s'get-value'},\nPOST:{%(_)s'post-key': %(_)s'post-value'},\nCOOKIES:{%(_)s'post-key': %(_)s'post-value'},\nMETA:{%(_)s'post-key': %(_)s'post-value'}>"))
     self.assertEqual(build_request_repr(request), repr(request))
     self.assertEqual(build_request_repr(request, path_override='/otherpath/', GET_override={'a': 'b'}, POST_override={'c': 'd'}, COOKIES_override={'e': 'f'}, META_override={'g': 'h'}),
                      str_prefix("<WSGIRequest\npath:/otherpath/,\nGET:{%(_)s'a': %(_)s'b'},\nPOST:{%(_)s'c': %(_)s'd'},\nCOOKIES:{%(_)s'e': %(_)s'f'},\nMETA:{%(_)s'g': %(_)s'h'}>"))
Пример #5
0
 def test_wsgirequest_repr(self):
     request = WSGIRequest({'PATH_INFO': '/somepath/', 'REQUEST_METHOD': 'get', 'wsgi.input': StringIO('')})
     request.GET = {u'get-key': u'get-value'}
     request.POST = {u'post-key': u'post-value'}
     request.COOKIES = {u'post-key': u'post-value'}
     request.META = {u'post-key': u'post-value'}
     self.assertEqual(repr(request), u"<WSGIRequest\npath:/somepath/,\nGET:{u'get-key': u'get-value'},\nPOST:{u'post-key': u'post-value'},\nCOOKIES:{u'post-key': u'post-value'},\nMETA:{u'post-key': u'post-value'}>")
     self.assertEqual(build_request_repr(request), repr(request))
     self.assertEqual(build_request_repr(request, path_override='/otherpath/', GET_override={u'a': u'b'}, POST_override={u'c': u'd'}, COOKIES_override={u'e': u'f'}, META_override={u'g': u'h'}),
                      u"<WSGIRequest\npath:/otherpath/,\nGET:{u'a': u'b'},\nPOST:{u'c': u'd'},\nCOOKIES:{u'e': u'f'},\nMETA:{u'g': u'h'}>")
Пример #6
0
def testQuickKegg():
    testPass = False
    myDict = QueryDict('key=6067cf4d7d814598a2c1b20f8372e591')
    myKeggRequest = WSGIRequest({
        'REQUEST_METHOD': 'GET',
        'wsgi.input': "heh?",
        'HTTP_X_REQUESTED_WITH': "XMLHttpRequest",
    })
    myKeggRequest.GET = myDict
    try:
        ret = pathTaxaJSON(myKeggRequest)
        retDat = json.loads(ret.content)
        if len(retDat['data']) != 0:
            testPass = True
    except Exception as errd:
        print "Error with quickKegg: ", errd
    # "6067cf4d7d814598a2c1b20f8372e591"
    #  get easy request copy from actual page, copy it here, run it
    #  Check response time and maybe number of outputs (both are ranges for variance sake)
    return testPass
Пример #7
0
 def test_wsgirequest_repr(self):
     request = WSGIRequest({
         'PATH_INFO': '/somepath/',
         'REQUEST_METHOD': 'get',
         'wsgi.input': StringIO('')
     })
     request.GET = {u'get-key': u'get-value'}
     request.POST = {u'post-key': u'post-value'}
     request.COOKIES = {u'post-key': u'post-value'}
     request.META = {u'post-key': u'post-value'}
     self.assertEqual(
         repr(request),
         u"<WSGIRequest\npath:/somepath/,\nGET:{u'get-key': u'get-value'},\nPOST:{u'post-key': u'post-value'},\nCOOKIES:{u'post-key': u'post-value'},\nMETA:{u'post-key': u'post-value'}>"
     )
     self.assertEqual(build_request_repr(request), repr(request))
     self.assertEqual(
         build_request_repr(request,
                            path_override='/otherpath/',
                            GET_override={u'a': u'b'},
                            POST_override={u'c': u'd'},
                            COOKIES_override={u'e': u'f'},
                            META_override={u'g': u'h'}),
         u"<WSGIRequest\npath:/otherpath/,\nGET:{u'a': u'b'},\nPOST:{u'c': u'd'},\nCOOKIES:{u'e': u'f'},\nMETA:{u'g': u'h'}>"
     )